Skip to content

TextOverlay ​

com.jsmacrosce.jsmacros.client.gui.overlays.TextOverlay

A WagYourGUI text-message overlay with a confirmation button that closes it.
The constructor stores the supplied text component; open the overlay through its parent to initialize it.

js
function showText(parent, font, text) {
 const TextOverlay = Java.type('com.jsmacrosce.jsmacros.client.gui.overlays.TextOverlay');  
 const overlay = new TextOverlay(10, 10, 180, 80, font, parent, text);  
 overlay.centered = false;  
 parent.openOverlay(overlay);  
}

Here parent, font, and text are caller-supplied overlay parent, native font, and native text component.

Constructors ​

new TextOverlay ​

new TextOverlay(int x, int y, int width, int height, Font textRenderer, IOverlayParent parent, Component text)#
Stores the overlay bounds, font, parent, and text; it does not open or initialize the overlay.

Parameters:

  • x: left edge of the overlay in screen GUI coordinates
  • y: top edge of the overlay in screen GUI coordinates
  • width: overlay width
  • height: overlay height
  • textRenderer: non-null font used to measure and draw the text
  • parent: non-null overlay host used to register widgets and close this overlay
  • text: non-null native text component to display

Fields ​

centered ​

centered: boolean#
Whether to horizontally offset the text toward the center of the overlay; defaults to true. The offset uses the full component's measured width, is clamped to the left text inset, and does not center wrapped lines or affect wrapping.

Methods ​

init ​

init(): void#
Clears this overlay's tracked buttons and registers a confirmation button with its parent; the button closes this overlay. Reinitializing clears the local tracking list but does not unregister buttons previously registered with the parent.

render ​

render(GuiGraphics drawContext, int mouseX, int mouseY, float delta): void#
Submits the overlay background and wrapped text, then forwards the hook to its buttons and any child overlay. This method does not consult the inherited visibility flag. When centered is true, the text's horizontal offset is based on the full component width and clamped to the left inset.

Parameters:

  • drawContext: graphics context receiving the overlay content
  • mouseX: current mouse x-coordinate, forwarded to widgets and a child overlay
  • mouseY: current mouse y-coordinate, forwarded to widgets and a child overlay
  • delta: frame value forwarded to widgets and a child overlay