Button
A pressable control that reports a named action when it fires. Tints the Panel on its node for idle, hovered and pressed, and can show a picture of its own in each state. Pair it with a Panel and a Text label. Goes under a Canvas.
On this page
Add it
+ Add node → Button, Menu Button creates a node with it already on. Already have a node for it? Add component → ButtonComponent.
From a script
A script on the same node writes these fields by name. ButtonComponent is the name to pass.
rgs
set_text("ButtonComponent", "action", "");
set_flag("ButtonComponent", "disabled", false);
set_colour("ButtonComponent", "normal", vec4(0.2, 0.2, 0.24, 1.0));
set_colour("ButtonComponent", "hovered", vec4(0.3, 0.3, 0.36, 1.0));
set_colour("ButtonComponent", "pressed", vec4(0.12, 0.12, 0.15, 1.0)); Fields
| Field | Script name | Kind | Default | What it does |
|---|---|---|---|---|
| Action | action | text | empty | Reported when this button fires, and read as held while a mouse or a finger holds it down. |
| Disabled | disabled | checkbox | off | When on, this button takes no input, and its face and the word on it dim. |
| Normal | normal | colour | #33333d | Tint when idle. |
| Hovered | hovered | colour | #4d4d5c | Tint under the pointer, or when focused. |
| Pressed | pressed | colour | #1f1f26 | Tint while held. |
| Hovered Texture | hovered_texture | asset | none | Shown instead of the Panel's picture while the pointer is over this button. |
| Pressed Texture | pressed_texture | asset | none | Shown instead of the Panel's picture while this button is held down. |
| Disabled Texture | disabled_texture | asset | none | Shown instead of the Panel's picture while this button is disabled. |