Listbox

A listbox item is used to place a list box in the rollout. This is another variant of the drop-down list in which the list is always fully displayed in the rollout. Unlike combobox, it has no edit-text field at the top and it is just a simple scrollable list. The user can scroll the list or click to select an item. The syntax is:

listbox <name> [ <caption> ] [ items:<array_of_strings> ] \

               [ selection:<number> ] [ height:<number> ]

The default alignment of listbox items is #left.

Example:

listbox selns items:obj_name_array

on selns selected i do

copy obj_array[i] pos:[rand_x, rand_y, rand_z]

selns.selection = 2

Parameters

items:

The array of text strings that are the items in the list.

selection:

The 1-based number of the currently selected item in the list. The default selection value is 1.

height:

The overall height of the listbox in number of item lines. Defaults to 10 lines. To have a listBox display exactly N items, set height to N.

Properties

<listbox>.items                 String

The item string array.

<listbox>.selection             Integer

The currently selected item number, 1-based. If the items list is an empty array, this value is 0.

<listbox>.selected              String

The text of the currently selected item. Can be used to replace individual items with resetting the entire items array. If the items list is an empty array, this value is undefined.

Events

on <listbox> selected <arg> do <expr>

Called when the user selects an item in the list. The <arg> argument contains the new current selection item number.

on <listbox> doubleClicked <arg> do <expr>

Called when the user double-clicks on an item in the list. Note that the on selected handler is always called on single clicks and on the first click of a double-click. The <arg> argument contains the number of the item double-clicked. For example,

listbox foo items:#(...)

on foo doubleClicked sel do ...

See also