TextPrompt
com.jsmacrosce.wagyourgui.overlays.TextPrompt
A WagYourGUI text-input overlay; open it through its parent to initialize and register its widgets.
Confirm passes the current input to the optional callback and closes after the callback returns normally;
it also closes when no callback was supplied. Cancel closes without calling it. The factory below takes a caller-supplied IOverlayParent, native Font, native Component message and JavaScript callback:
js
function showTextPrompt(parent, font, message, onAccept) {
const TextPrompt = Java.type('com.jsmacrosce.wagyourgui.overlays.TextPrompt');
const prompt = new TextPrompt(10, 10, 260, 100, font, message, '', parent, JavaWrapper.methodToJava(onAccept));
parent.openOverlay(prompt);
return prompt;
}Constructors
new TextPrompt
new TextPrompt(int x, int y, int width, int height, Font textRenderer, Component message, String defaultText, IOverlayParent parent, Consumer<String> accept)#Stores the overlay configuration without opening or initializing it; opening through the parent performs widget registration.
Parameters:
x: left edge in GUI coordinatesy: top edge in GUI coordinateswidth: width in GUI coordinatesheight: height in GUI coordinatestextRenderer: non-null font used for the prompt and its widgetsmessage: non-null native message component, stored by referencedefaultText: initial input text; null is treated as an empty stringparent: non-null overlay hostaccept: optional callback receiving the input content on Confirm, before the overlay closes
Fields
ti
Methods
init
init(): void#Clears local widget tracking, registers a new input and the Cancel and Confirm buttons, then requests focus through the parent and marks the input selected; this is not a select-all operation. Reinitialization replaces the input with the original default text; prior parent registrations are not removed.
render
render(GuiGraphics drawContext, int mouseX, int mouseY, float delta): void#Submits the background and horizontally centered message lines, then forwards the hook to widgets and any child overlay. The stored message is split on each call using the current width minus four. Lines start at
y + 5 and advance by the font line height, without an overlay-height limit, so long messages can overlap widgets. This method does not consult the inherited visibility flag.Parameters:
drawContext: graphics context receiving the submitted drawing operationsmouseX: mouse position in GUI coordinates, forwarded to widgets and child overlaymouseY: mouse position in GUI coordinates, forwarded to widgets and child overlaydelta: frame value forwarded to widgets and child overlay