|
A list control gives the user a list of string items to choose from. There are two built-in classes that implement list-control<%>:
choice% – presents the list in a popup menu (so the user can choose only one item at a time)
list-box% – presents the list in a scrolling box, allowing the use to choose one item (if the style includes 'single) or any number of items
In either case, the set of user-selectable items can be changed dynamically.
item : string |
Adds a new item to the list of user-selectable items. The current selection is unchanged (unless the list control is an empty choice control, in which case the new item is selected).
Removes all user-selectable items from the control.
(send a-list-control find-string s) |
s : string |
Finds a user-selectable item matching the given string. If no matching choice is found, #f is returned, otherwise the index of the matching choice is returned (items are indexed from 0).
(send a-list-control get-number) → nonnegative-exact-integer? |
Returns the number of user-selectable items in the control (which is also one more than the greatest index in the list control).
(send a-list-control get-selection) |
Returns the index of the currently selected item (items are indexed from 0). If the choice item currently contains no choices or no selections, #f is returned. If multiple selections are allowed and multiple items are selected, the index of the first selection is returned.
(send a-list-control get-string n) |
→ (and/c immutable? label-string?) |
n : nonnegative-exact-integer? |
Returns the item for the given index (items are indexed from 0). If the provided index is larger than the greatest index in the list control, an exn:fail:contract exception is raised.
(send a-list-control get-string-selection) |
→ (or/c (and/c immutable? label-string?) false/c) |
Returns the currently selected item. If the control currently contains no choices, #f is returned. If multiple selections are allowed and multiple items are selected, the first selection is returned.
(send a-list-control set-selection n) → void? |
n : nonnegative-exact-integer? |
Selects the item specified by the given index (items are indexed from 0). If the given index larger than the greatest index in the list control, an exn:fail:contract exception is raised.
In a list box control, all other items are deselected, even if multiple selections are allowed in the control. See also select in list-box%.
The control’s callback procedure is not invoked when this method is called.
The list control’s selection can be changed by the user clicking the control, and such changes do not go through this method; use the controlcallback procedure (provided as an initialization argument) to monitor selection changes.
(send a-list-control set-string-selection s) → void? |
s : string |
Selects the item that matches the given string. If no match is found in the list control, an exn:fail:contract exception is raised.
In a list box control, all other items are deselected, even if multiple selections are allowed in the control. See also select in list-box%.
The control’s callback procedure is not invoked when this method is called.
The list control’s selection can be changed by the user clicking the control, and such changes do not go through this method; use the controlcallback procedure (provided as an initialization argument) to monitor selection changes.