Skip to content

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 coordinates
  • y: top edge in GUI coordinates
  • width: width in GUI coordinates
  • height: height in GUI coordinates
  • textRenderer: non-null font used for the prompt and its widgets
  • message: non-null native message component, stored by reference
  • defaultText: initial input text; null is treated as an empty string
  • parent: non-null overlay host
  • accept: optional callback receiving the input content on Confirm, before the overlay closes

Fields ​

ti ​

The input widget registered by the latest init() call; null before initialization and replaced on each initialization. Confirm reads this field's current content. Reassigning the field does not replace the registered widget.

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 operations
  • mouseX: mouse position in GUI coordinates, forwarded to widgets and child overlay
  • mouseY: mouse position in GUI coordinates, forwarded to widgets and child overlay
  • delta: frame value forwarded to widgets and child overlay