1.7 KiB
UIToggleComponent — giriş
← UIToggleComponent · ← Master
mchorse.mappet.api.ui.components
Class UIToggleComponent java.lang.Object
mchorse.mappet.api.ui.components.UIComponent mchorse.mappet.api.ui.components.UILabelBaseComponent
mchorse.mappet.api.ui.components.UIToggleComponent
public class UIToggleComponent extends UILabelBaseComponent
Toggle UI component.
This component allows users to input boolean value (yes/no, true/false, 1/0). The value that gets written to UI context's data (if ID is present) is boolean.
This component can be created using IMappetUIBuilder.toggle(String) method.
function main(c) { var ui = mappet.createUI(c, "handler").background(); var trackpad = ui.toggle("Show", false).id("toggle"); var label = ui.label("You can see this label").id("label");
trackpad.rxy(0.5, 0.5).wh(160, 20).anchor(0.5); label.rx(0.5).ry(0.5, 25).wh(160, 20).anchor(0.5).labelAnchor(0.5); c.getSubject().openUI(ui); }
function handler(c) { var uiContext = c.getSubject().getUIContext(); var data = uiContext.getData();
if (uiContext.getLast() === "toggle") { uiContext.get("label").visible(uiContext.getData().getBoolean("toggle")); } }
Field Summary Fields
Field and Description
Modifier and Type boolean state
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