UI Dropdown
Drop-down selector over a list of options.
Type: UIDropdownNode · Category: UI & Interface · Also found as: uidropdown
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
size |
vec2 | (360, 28) |
Width and height (px). Range 4 to 1280. |
label |
string | "Select" |
Caption shown next to the control. |
selectedIndex |
integer | 0 |
Index of the selected item (-1 = none). Range 0 to 32. |
defaultIndex |
integer | 0 |
Index restored by reset. Range 0 to 32. |
labelWidth |
number | 130 |
Width reserved for the label (px); 0 = none. Range 0 to 300. |
isOpen |
boolean | false |
List open now. |
Plus the common properties every node has.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
UIDropdownNode:connect(event, handler)
Section titled “UIDropdownNode:connect(event, handler)”Connects a handler to one of this node’s events: value_changed (The value changed); the tree events; custom ones.
self.node:connect("value_changed", function(value, source) Log.info("value_changed") end)eventUIDropdownNodeEvent|stringhandlerfun(value:any, source: UIDropdownNode)
Returns integer id Connection id for disconnect
UIDropdownNode:get_property(path)
Section titled “UIDropdownNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("size")pathUIDropdownNodeProperty|string
Returns any
UIDropdownNode:set_property(path, value, y)
Section titled “UIDropdownNode:set_property(path, value, y)”Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.
self.node:set_property("size", 100, 50)pathUIDropdownNodeProperty|stringvalueanyy?number
In a scene file
Section titled “In a scene file”{ "type": "UIDropdownNode", "name": "UIDropdown", "position": [ 0, 0 ], "properties": { "size": [ 360, 28 ], "label": "Select", "selectedIndex": 0 }}