button_react_util¶
Source: base/tealdef/gui/main/button_react_util.d.tl
Notes
Shortcut functions that build builtin.Button and builtin.ToggleButton nodes with a text,
an icon or both as content. Load the module with
ug_require "/gui/main/button_react_util.tl".
ButtonReactUtil¶
record global base/tealdef/gui/main/button_react_util.d.tl:3
global record ButtonReactUtil
Load: local button_react_util = ug_require "/gui/main/button_react_util.tl"
Notes
Functions that return ready-made button nodes (text, icon, icon plus text, icon toggle).
Details
Each function returns a TreeNodeId that you place in a layout like any other node.
Unless noted otherwise, the button is enabled, its content keeps focus traversal
(disableFocusableRecursive = false) and text uses the style class font-scale-body.
Functions
makeTextButton(className : string, text : string, onClick : function(), tooltip : string, disabled? : boolean, textClass? : string, disableFocusableRecursive? : boolean) : TreeNodeId base/tealdef/gui/main/button_react_util.d.tl:4
Call as button_react_util.makeTextButton
Notes
Builds a builtin.Button whose content is a single builtin.TextView.
| Parameter | Type | Description |
|---|---|---|
className |
string |
Style class of the button. |
text |
string |
Button text. |
onClick |
function() |
Called when the button is clicked. |
tooltip |
string |
Tooltip of the button. |
disabled? |
boolean |
If true, the button is disabled. Note that this parameter is inverted compared to the enabled parameter of the icon buttons. |
textClass? |
string |
Style class of the text view (default font-scale-body). |
disableFocusableRecursive? |
boolean |
Passed to the button's meta.disableFocusableRecursive (default false). |
Returns TreeNodeId: The button node.
makeIconToggleButton(className : string, path : string, onClick : function(v : boolean), tooltip : string, enabled? : boolean, tag? : string, disableFocusableRecursive? : boolean, value? : boolean) : TreeNodeId base/tealdef/gui/main/button_react_util.d.tl:13
Call as button_react_util.makeIconToggleButton
Notes
Builds a builtin.ToggleButton with an icon as content and a boolean value callback.
| Parameter | Type | Description |
|---|---|---|
className |
string |
Style class of the toggle button. |
path |
string |
Image path of the icon. |
onClick |
function(v : boolean) |
Called with the new state (true = pressed) when the user toggles the button. |
tooltip |
string |
Tooltip of the button. |
enabled? |
boolean |
If false, the button is disabled (default true). |
tag? |
string |
Value for the button's meta.tag. |
disableFocusableRecursive? |
boolean |
Passed to the button's meta.disableFocusableRecursive (default false). |
value? |
boolean |
Current state of the toggle button (nil counts as false). |
Returns TreeNodeId: The toggle button node.
Details
The underlying toggle button works with integers (0/1). This helper converts them:
value is passed as 1 when true, otherwise 0, and onClick receives
true when the button's new value is 1.
makeIconButton(className : string, path : string, onClick : function(), tooltip : string, enabled? : boolean, tag? : string, disableFocusableRecursive? : boolean) : TreeNodeId base/tealdef/gui/main/button_react_util.d.tl:23
Call as button_react_util.makeIconButton
Notes
Builds a builtin.Button whose content is a builtin.ImageView scaled with AutoFit.
| Parameter | Type | Description |
|---|---|---|
className |
string |
Style class of the button. |
path |
string |
Image path of the icon, e.g. "::/gui/main/icons/...". |
onClick |
function() |
Called when the button is clicked. |
tooltip |
string |
Tooltip of the button. |
enabled? |
boolean |
If false, the button is disabled (default true). |
tag? |
string |
Value for the button's meta.tag. |
disableFocusableRecursive? |
boolean |
Passed to the button's meta.disableFocusableRecursive (default false). |
Returns TreeNodeId: The button node.
Used in the base game: 14 times in 4 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:3360
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:4984
base/content/gui/gui/menu/main_page.tl:513
base/content/gui/gui/entity_window/entity_window_util.tl:1729
makeIconTextButton(className : string, path : string, text : string, onClick : function(), tooltip : string, enabled? : boolean, tag? : string, textClass? : string, disableFocusableRecursive? : boolean) : TreeNodeId base/tealdef/gui/main/button_react_util.d.tl:32
Call as button_react_util.makeIconTextButton
Notes
Builds a builtin.Button with an icon followed by a text in a horizontal box.
| Parameter | Type | Description |
|---|---|---|
className |
string |
Style class of the button. |
path |
string |
Image path of the icon. |
text |
string |
Text shown to the right of the icon. |
onClick |
function() |
Called when the button is clicked. |
tooltip |
string |
Tooltip of the button. |
enabled? |
boolean |
If false, the button is disabled (default true). |
tag? |
string |
Value for the button's meta.tag. |
textClass? |
string |
Style class of the text view (default font-scale-body). |
disableFocusableRecursive? |
boolean |
Passed to the button's meta.disableFocusableRecursive (default false). |
Returns TreeNodeId: The button node.