Skip to content

UI Button

Interactive clickable button with hovered, normal, and pressed visual feedback and event callbacks.

Type: UIButtonNode · Category: UI & Interface · Also found as: uibutton

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.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

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)
  • event UIButtonNodeEvent|string
  • handler fun(value: any, source: UIButtonNode)

Returns integer id Connection id for disconnect

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("size")
  • path UIButtonNodeProperty|string

Returns any

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.” a field of the node’s script.

self.node:set_property("size", 100, 50)
  • path UIButtonNodeProperty|string
  • value any
  • y? number
{
"type": "UIButtonNode",
"name": "UIButton",
"position": [
0,
0
],
"properties": {
"size": [
200,
36
],
"text": "Button",
"fontSize": 18
}
}