GaldurCheckbox
classclient onlysince 0.1.0com.galdurstudio.galdurui.api.widget.GaldurCheckbox
Themed checkbox.
The widget does not store the state: it reads it every frame from a
supplier and asks for changes through a callback. The state lives elsewhere (a
GaldurWindow handle, for instance), so it survives the widget being rebuilt on
resize.
boolean[] sound = {false};column.addChild(GaldurCheckbox.of(Component.literal("Enable sound"), () -> sound[0], value -> sound[0] = value));public class GaldurCheckbox extends AbstractWidget
PACKAGEapi.widget
SIDEclient only
EXTENDSAbstractWidget
Constructors 1
GaldurCheckbox
protectedprotected GaldurCheckbox(Component label, BooleanSupplier checked, Consumer<Boolean> onToggle)
PARAMETERS
labelComponenttext right of the box
checkedBooleanSuppliersupplier of the current state, called every frame
onToggleConsumer<Boolean>receives the wanted value when the player toggles the box
Methods 2
of
staticpublic static GaldurCheckbox of(Component label, BooleanSupplier checked, Consumer<Boolean> onToggle)
PARAMETERS
labelComponent—
checkedBooleanSupplier—
onToggleConsumer<Boolean>—
RETURNSGaldurCheckbox — a checkbox at (0, 0), for a layout to place
onClick
public void onClick(double mouseX, double mouseY, int button)
Only remembers the press: the box toggles on release, so the player can cancel by releasing elsewhere.
PARAMETERS
mouseXdouble—
mouseYdouble—
buttonint—