Skip to content

AnnotatedCheckBox ​

com.jsmacrosce.wagyourgui.elements.AnnotatedCheckBox

A message-bearing checkbox with a square toggle area at the widget's right edge.
The factory takes a caller-supplied native font, label component and JavaScript callback. Register the returned widget with a host for normal GUI input and rendering.

js
function makeCheckBox(font, label, onChanged) {
 const CheckBox = Java.type('com.jsmacrosce.wagyourgui.elements.AnnotatedCheckBox');  
 return new CheckBox(10, 10, 140, 16, font, Color.rgb(0x00, 0x00, 0x00), Color.rgb(0xFF, 0xFF, 0xFF),  
   Color.rgb(0x80, 0x80, 0x80), Color.rgb(0xFF, 0xFF, 0xFF), label, false,  
   JavaWrapper.methodToJava(button => onChanged(button.value)));  
}

Constructors ​

new AnnotatedCheckBox ​

new AnnotatedCheckBox(int x, int y, int width, int height, Font textRenderer, int color, int borderColor, int highlightColor, int textColor, Component message, boolean initialValue, Consumer<Button> onPress)#
Sets up colors and cached label layout through the parent button, then stores the checked state and disables horizontal label centering. Does not invoke the press callback or register the widget with a host. Colors use packed ARGB; zero alpha with nonzero RGB is made opaque.

Parameters:

  • x: GUI left coordinate
  • y: GUI top coordinate
  • width: total widget width, including the square toggle area
  • height: widget height and square toggle area side length
  • textRenderer: non-null native font used to render and wrap the label
  • color: checked square fill when not hovered
  • borderColor: square outline unless unchecked and hovered
  • highlightColor: checked hover fill or unchecked hover outline
  • textColor: label text color
  • message: non-null native label component
  • initialValue: initial checked state
  • onPress: optional callback receiving this widget after its state toggles

Fields ​

value ​

value: boolean#
Mutable checked state used by the next visible contents hook; direct assignment does not invoke the press callback or refresh label layout.

Methods ​

onPress ​

onPress(InputWithModifiers input): void#
Toggles the checked state before invoking the optional inherited press callback with this widget. A direct call does not check active or visible state; a callback failure propagates without rolling back the toggle.

Parameters:

  • input: activation input forwarded to the parent, which does not use it

renderContents ​

renderContents(GuiGraphics drawContext, int mouseX, int mouseY, float delta): void#
Submits the cached label and right-edge checkbox square when visible; hidden widgets submit nothing and retain the previous hover flag. Label submission precedes storing hover as mouse-inside-and-active or forceHover; forced hover also works while inactive. A checked square uses the idle or hover fill; an unchecked hovered square uses the hover outline. Does not call the parent contents hook, forward to children, toggle the value or invoke the press callback.

Parameters:

  • drawContext: graphics context receiving the drawing operations
  • mouseX: GUI x-coordinate used to determine hover
  • mouseY: GUI y-coordinate used to determine hover
  • delta: frame value, unused by this implementation

setMessage ​

setMessage(Component message): void#
Updates the native label and caches wrapping in the left region using width - height - 4, with visible line count and vertical offset based on current height. Changing the widget size does not refresh this cache; call this method again after resizing. Does not change the checked state or invoke the press callback.

Parameters:

  • message: non-null native label component