1.8 KiB
UIButtonComponent — giriş
← UIButtonComponent · ← Master
mchorse.mappet.api.ui.components
Class UIButtonComponent java.lang.Object
mchorse.mappet.api.ui.components.UIComponent mchorse.mappet.api.ui.components.UILabelBaseComponent
mchorse.mappet.api.ui.components.UIButtonComponent
public class UIButtonComponent extends UILabelBaseComponent
Clickable button component.
This component displays a flat colored box with a label on top, which allows users to trigger the handler script. The value that gets written to UI context's data (if ID is present) is how many times the button was pressed.
This component can be created using IMappetUIBuilder.button(String) method.
function main(c) { var ui = mappet.createUI(c, "handler").background(); var button = ui.button("Start...").id("button");
button.rxy(0.5, 0.5).wh(160, 20).anchor(0.5); c.getSubject().openUI(ui); }
function handler(c) { var uiContext = c.getSubject().getUIContext();
if (uiContext.getLast() === "button") { var data = uiContext.getData(); var pressed = data.getInt("button");
if (pressed >= 100) { c.send("We have a winner!"); }
uiContext.get("button").label("You pressed: " + pressed); } }
Field Summary Fields
Modifier and Type Field and Description java.lang.Integer background
Fields inherited from class mchorse.mappet.api.ui.components.UILabelBaseComponent hasBackground, label
Fields inherited from class mchorse.mappet.api.ui.components.UIComponent changedProperties, context, DELAY, enabled, h, id, keybinds, marginBottom, marginLeft, marginRight, marginTop, tooltip, tooltipDirection, updateDelay, visible, w, x, y
Constructor Summary Constructors
Constructor and Description