UI Button
Interactive clickable button with hovered, normal, and pressed visual feedback and event callbacks.
Type: UIButtonNode · Category: UI & Interface · Also found as: uibutton
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
size |
vec2 | (200, 36) |
Width and height (px). Range 4 to 1280. |
text |
string | "Button" |
Button caption. |
fontSize |
number | 18 |
Text size (px). Range 8 to 48. |
icon |
enum: None, Digit0, Digit1, Digit2, Digit3, Digit4, Digit5, Digit6, Digit7, Digit8, Digit9, A … |
None |
Icon shown (Font Awesome). |
iconSize |
number | 0 |
Icon size (px). Range 0 to 64. |
normalColor |
color | #232731ff |
Fill colour at rest. |
hoverColor |
color | #323848ff |
Fill colour under the mouse. |
pressedColor |
color | #2563ebff |
Fill colour while pressed. |
borderColor |
color | #4b5366ff |
Colour of the border. |
textColor |
color | #eef0f6ff |
Colour of the text. |
align |
enum: Left, Center, Right |
Center |
Horizontal text alignment. |
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.
UIButtonNode:connect(event, handler)
Section titled “UIButtonNode:connect(event, handler)”Connects a handler to one of this node’s events: clicked (The button was clicked); the tree events; custom ones.
self.node:connect("clicked", function(value, source) Log.info("clicked") end)eventUIButtonNodeEvent|stringhandlerfun(value:any, source: UIButtonNode)
Returns integer id Connection id for disconnect
UIButtonNode:get_property(path)
Section titled “UIButtonNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("size")pathUIButtonNodeProperty|string
Returns any
UIButtonNode:set_property(path, value, y)
Section titled “UIButtonNode: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)pathUIButtonNodeProperty|stringvalueanyy?number
In a scene file
Section titled “In a scene file”{ "type": "UIButtonNode", "name": "UIButton", "position": [ 0, 0 ], "properties": { "size": [ 200, 36 ], "text": "Button", "fontSize": 18 }}