Skip to content

2.00 Button

Lokasenna edited this page Jun 24, 2018 · 1 revision

It's a button. You click on it. Things happen.

A button

Parameters

z, x, y, w, h, caption, func[, ...]

Required

z               Element depth, used for hiding and disabling layers. 1 is the highest.
x, y            Coordinates of top-left corner
w, h            Button size
caption	        Label
func            Function to perform when clicked. 

Note that you only need give a reference to the function:

GUI.New("my_button", "Button", 1, 32, 32, 64, 32, "Button", my_func)

Unless the function is returning a function (hey, Lua is weird), you don't want to actually run it:

GUI.New("my_button", "Button", 1, 32, 32, 64, 32, "Button", my_func())

Optional

...             Any parameters to pass to that function, separated by commas as they
                would be if calling the function directly.

Additional parameters

r_func          Function to perform when right-clicked
r_params        If provided, any parameters to pass to that function
font            Button label's font
col_txt         Button label's color

col_fill        Button color. 
                
                If you change this at any time after having run GUI.Init(), call 
                GUI.elms.my_button:init() so the buffer can be redrawn.

Methods

:exec([r])

Programmatically force a button-click and run func, i.e. for allowing buttons to have an associated hotkey.

r               Boolean, optional. r = true will run r_func instead.