List Boxes
Extends: LISTBOX > CONTROL > WIDGET
A LISTBOX displays various entries so you can select one of these entries.
A POPUP is a list box that displays its items as a drop-down list.
LBAPPEND
Part of: LISTBOX
Appends one or more items to the list box.
Syntax
ASK "LISTBOX [LBAPPEND [ONE TWO THREE]]
Description
LBAPPEND appends one or more items to the list box. If the input to LBAPPEND is a list, each list element is treated as a separate list box entry. Outputs the index of the last inserted item.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped ASK “LISTBOX [LBAPPEND [ONE TWO THREE]] Result: 2
LBCLEAR
Part of: LISTBOX
Erases the contents of the list box.
Syntax
ASK "LISTBOX [LBCLEAR]
Description
LBCLEAR erases the contents of the list box.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped ASK “LISTBOX [LBAPPEND [ONE TWO THREE]] WAIT 1000 ASK “LISTBOX [LBCLEAR]
LBFIND
Part of: LISTBOX
Finds a list box item.
Syntax
ASK "LISTBOX [LBFIND "TWO]
Description
LBFIND searches the text in the list box and outputs the index of the item if the text is found (case insensitive). If the text cannot be found, LBFIND outputs -1.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped ASK “LISTBOX [LBAPPEND [ONE TWO THREE]] ASK “LISTBOX [LBFIND “TWO] Result: 1
INDEX
Part of: LISTBOX
Controls the index of a selected list box item.
Syntax
GPROP "LISTBOX "INDEX
PPROP "LISTBOX "INDEX number
Description
INDEX reports zero-based index of the currently selected item of a list box. The value is -1 if no item has been selected. Setting the INDEX property causes the item with the given item to be selected, or all items to be deselected if the input value is -1.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped ASK “LISTBOX [APPEND [ONE TWO THREE]] GPROP “LISTBOX “INDEX Result: 2
LBINSERT
Part of: LISTBOX
Inserts one or more items into a list box.
Syntax
ASK "LISTBOX [LBINSERT "FOUR]
Description
LBINSERT inserts one or more items in front of the currently selected item. If no item is selected, the procedure appends the item(s) to the list box contents. If the input to LBINSERT is a list, each list element is treated as a separate list box entry. Outputs the index of the last inserted item.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped ASK “LISTBOX [LBAPPEND [ONE TWO THREE]] PPROP “LISTBOX “INDEX 2 ASK “LISTBOX [LBINSERT “BETWEEN.2.AND.3] Result: 2
LBITEM
Part of: LISTBOX
Outputs a list box item by index.
Syntax
ASK "LISTBOX [LBITEM 0]
Description
LBITEM outputs the list box item at position index
(0-based). If the index is out of range, LBITEM outputs the empty word.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped ASK “LISTBOX [LBAPPEND [ONE TWO THREE]] ASK “LISTBOX [LBITEM 0] Result: ONE
ITEMCOUNT
Part of: LISTBOX
Reports the number of list box items.
Syntax
GPROP "LISTBOX "ITEMCOUNT
Description
ITEMCOUNT reports the number of list box items. The property is read-only.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped ASK “LISTBOX [APPEND [ONE TWO THREE]] GPROP “LISTBOX “ITEMCOUNT Result: 3
ITEMS
Part of: LISTBOX
Controls the contents of the listbox.
Syntax
GPROP "LISTBOX "ITEMS
PPROP "LISTBOX "ITEMS [ONE TWO THREE]
Description
The ITEMS property outputs a list of all items in the list box. Setting this property sets all items in the listbox.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped PPROP “LISTBOX “ITEMS [ONE TWO THREE]
LBREMOVE
Part of: LISTBOX
Removes a list box item.
Syntax
ASK "LISTBOX [LBREMOVE 0]
Description
LBREMOVE removes the item at the given index position. If the index is out of range, the procedure does nothing.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped PPROP “LISTBOX “ITEMS [ONE TWO THREE] ASK “LISTBOX [LBREMOVE 1]
LBREPLACE
Part of: LISTBOX
Replace a listbox item text.
Syntax
ASK "LISTBOX [LBREPLACE "OK]
Description
LBREPLACE replaces the currently selected item with another text. If the list box is sorted, the items may be re-sorted. The item remains selected. If no item is selected, the procedure does nothing.
Examples
DRAW ; Drop a LISTBOX widget from the Toolbox > Controls LISTBOX dropped PPROP “LISTBOX “ITEMS [ONE TWO THREE] PPROP “LISTBOX “INDEX 1 ASK “LISTBOX [LBREPLACE “OK]