Class Button
java.lang.Object
dev.xichil.mvui.Entry
dev.xichil.mvui.Button
A push button, drawn as the version's vanilla button. Use it for actions (save, reset, open another screen) and in
the footer for "Done".
Button.builder("details")
.label(Text.translatable("mymod.details", "Details..."))
.onPress(() -> host.open(detailsScreen(host)))
.build();
Button.builder("done").label(UiTexts.DONE).onPress(host::back).build();
Required: label, onPress. After onPress returns, the host
refreshes the current screen, so labels and enabled states reflect what the action changed.
-
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 Button.BuilderStarts building a button.label()The text on the button, from the mod's supplier.voidpress()RunsonPress, as a click does.
-
Method Details
-
builder
Starts building a button.- Parameters:
id- the button's id, unique within its screen- Returns:
- a new builder
- Throws:
IllegalArgumentException- ifidis invalid
-
label
The text on the button, from the mod's supplier.- Returns:
- the text drawn on the button
-
press
public void press()RunsonPress, as a click does. Backends call it only while the button isEntry.enabled(); this method itself doesn't check. WhateveronPressthrows passes through. -
accept
Description copied from class:EntryCalls theEntryVisitormethod for this entry's type (visitButtonfor aButton, …) and returns its result. ASectionvisits as its header, aNumberFieldas itsTextInput.
-