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 coordinatey: GUI top coordinatewidth: total widget width, including the square toggle areaheight: widget height and square toggle area side lengthtextRenderer: non-null native font used to render and wrap the labelcolor: checked square fill when not hoveredborderColor: square outline unless unchecked and hoveredhighlightColor: checked hover fill or unchecked hover outlinetextColor: label text colormessage: non-null native label componentinitialValue: initial checked stateonPress: 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 operationsmouseX: GUI x-coordinate used to determine hovermouseY: GUI y-coordinate used to determine hoverdelta: frame value, unused by this implementation
setMessage
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