CheckBoxWidgetHelper
com.jsmacrosce.jsmacros.client.api.helper.screen.CheckBoxWidgetHelper
A checkbox widget whose checked state can be changed by the player or a script.
Scripted changes invoke the builder's change callback through the widget's press handler.
js
const screen = Hud.createScreen("a screen", true);
screen.setOnInit(JavaWrapper.methodToJava(function (self) {
const box = self.checkBoxBuilder()
.pos(10, 20)
.size(20, 20)
.message("enabled")
.action(JavaWrapper.methodToJava(function (btn) {
// the action fires on a scripted change as well as a player click
Chat.log(`now ${btn.isChecked()}`);
}))
.build();
// setting a different state invokes the action
box.setChecked(true);
Chat.log(`checked: ${box.isChecked()}`);
}));
Hud.openScreen(screen);Available in scripts as Widgets.CheckBox.
Nested types
Constructors
new CheckBoxWidgetHelper
Wraps a checkbox with the default helper z-index of
0.Parameters:
btn: the checkbox to wrap
Methods
isChecked
Returns the widget's current checked state.
Returns:
true if this button is checked, false otherwise.setChecked
Sets the checked state by invoking the press handler if the requested state differs from the current state. A changed state invokes the builder's change callback; an unchanged state does nothing.
Parameters:
checked: whether to check or uncheck this button
Returns: self for chaining.
toggle
Toggles the checked state through the widget's press handler, invoking its change callback.
Returns: self for chaining.