Skip to content

2.00 Listbox

Lokasenna edited this page Jun 28, 2018 · 2 revisions

Provides a scrolling list of options, from which the user can select one or more.

A listbox

Parameters

z, x, y, w, h[, list, multi, caption, pad]

Required

z               Element depth, used for hiding and disabling layers. 1 is the highest.
x, y            Coordinates of top-left corner
w, h            Width and height of the text editor

Optional

list            Accepts either a comma-separated string of options or a table

                If you change the list at run-time using a comma-separated string,
                you'll need to call GUI.elms.my_list:init() afterward to have the
                string parsed into a table.
                
multi           Boolean. Can the user select multiple items (Ctrl, Shift)?
caption         Label shown to the left of the text editor
pad	            Padding between the label and the text editor

Additional parameters

cap_bg          Color to be drawn underneath the label. Defaults to "wnd_bg"
bg              List background. Defaults to "elm_bg"
shadow          Boolean. Draw a shadow beneath the label?
color           Text color
font_a          Caption font
font_b          List font

Methods

GUI.Val("my_list")

Returns either a single item number (multi = false), or a table (multi = true) with the indices of each selected item.

GUI.Val("my_list", new_vals)

Accepts a table of boolean values for items to be selected or not selected.

:wnd_recalc()

If your script needs to resize the listbox, move it around, etc, run this afterward so it can update a few internal values.