Class Checkbox
java.lang.Object
dev.xichil.mvui.Entry
dev.xichil.mvui.Checkbox
A check box with its label to the right, like vanilla's
Checkbox (1.16+; older versions get an equivalent
drawing). Holds the same kind of value as a Toggle, drawn differently: use check boxes for lists of
independent yes/no choices ("include: [x] options [ ] keybinds [x] servers"), a toggle for settings.
Checkbox.builder("includeKeys")
.label(Text.translatable("mymod.includeKeys", "Include key bindings"))
.value(() -> export.includeKeys)
.onChange(checked -> export.includeKeys = checked)
.build();
The value lives in the mod, as with a toggle. Required: label, value,
onChange. Can't be in a MenuScreen's footer.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(EntryVisitor<R> visitor) Calls theEntryVisitormethod for this entry's type (visitButtonfor aButton, …) and returns its result.static Checkbox.BuilderStarts building a check box.booleanchecked()Whether the box is checked: the mod's current value, from itsvaluesupplier.label()The text to the right of the box, from the mod's supplier.voidset(boolean checked) PassescheckedtoonChange, even if it equals the current value.voidtoggle()Passes the opposite ofchecked()toonChange, as a click does.
-
Method Details
-
builder
Starts building a check box.- Parameters:
id- the check box's id, unique within its screen- Returns:
- a new builder
- Throws:
IllegalArgumentException- ifidis invalid
-
label
The text to the right of the box, from the mod's supplier.- Returns:
- the text drawn to the right of the box
-
checked
public boolean checked()Whether the box is checked: the mod's current value, from itsvaluesupplier.- Returns:
trueif the box is checked
-
set
public void set(boolean checked) PassescheckedtoonChange, even if it equals the current value.- Parameters:
checked- the new value
-
toggle
public void toggle()Passes the opposite ofchecked()toonChange, as a click does. -
accept
Description copied from class:EntryCalls theEntryVisitormethod for this entry's type (visitButtonfor aButton, …) and returns its result. ASectionvisits as its header, aNumberFieldas itsTextInput.
-