1.9 KiB
IMappetUIContext.sendToPlayer
c.getSubject().send("Welcome back to the world!"); } }
getLast
java.lang.String getLast()
Get the ID of last edited UI component.
If there were multiple UI elements were changed (see UIComponent.updateDelay(int)), then only the last one will be provided.
function main(c) { var ui = mappet.createUI(c, "handler").background(); var title = ui.label("...").id("title"); var name = ui.textbox().id("name"); var lastname = ui.textbox().id("lastname");
// Place two text fields in the middle of the screen name.rxy(0.5, 0.5).wh(140, 20).anchor(0.5); lastname.rx(0.5).ry(0.5, 25).wh(140, 20).anchor(0.5); title.rx(0.5).y(20).wh(140, 20).anchorX(0.5); title.labelAnchor(0.5, 0.5);
c.getSubject().openUI(ui); }
function handler(c) { var uiContext = c.getSubject().getUIContext(); var last = uiContext.getLast();
// Depending on the last value, update the title accordingly if (last === "name") { uiContext.get("title").label("Name: " + uiContext.getData().getString("name")); } else if (last === "lastname") { uiContext.get("title").label("Last name: " + uiContext.getData().getString("lastname")); } }
getHotkey
java.lang.String getHotkey()
Get the ID of the last pressed hot key.
If no keybind was pressed, it will be an empty string (""). See UIComponent.keybind(int, String, String, boolean, boolean, boolean) method for an example.
getContext
java.lang.String getContext()
Get the ID of the last context menu item.
If no context menu was activated, it will be an empty string (""). See UIComponent.context(String, String, String, int) method for an example.
get
UIComponent get(java.lang.String id)