3.28 list-control<%>

► |  | The Racket Graphical Interface Toolkit

1 | Windowing
2 | Widget Gallery
3 | Windowing Classes
4 | Windowing Functions
5 | Editors
6 | Snip and Style Classes
7 | Editor Classes
8 | Editor Functions
9 | WXME Decoding
10 | Preferences
11 | Dynamic Loading
12 | Startup Actions
13 | Platform Dependencies
| Index

▼ | 3 | Windowing Classes

3.1 | area<%>
3.2 | area-container<%>
3.3 | area-container-window<%>
3.4 | button%
3.5 | canvas<%>
3.6 | canvas%
3.7 | check-box%
3.8 | checkable-menu-item%
3.9 | choice%
3.10 | clipboard-client%
3.11 | clipboard<%>
3.12 | combo-field%
3.13 | control<%>
3.14 | column-control-event%
3.15 | control-event%
3.16 | cursor%
3.17 | dialog%
3.18 | event%
3.19 | frame%
3.20 | gauge%
3.21 | group-box-panel%
3.22 | grow-box-spacer-pane%
3.23 | horizontal-pane%
3.24 | horizontal-panel%
3.25 | key-event%
3.26 | labelled-menu-item<%>
3.27 | list-box%
3.28 | list-control<%>
3.29 | menu%
3.30 | menu-bar%
3.31 | menu-item<%>
3.32 | menu-item%
3.33 | menu-item-container<%>
3.34 | message%
3.35 | mouse-event%
3.36 | pane%
3.37 | panel%
3.38 | popup-menu%
3.39 | printer-dc%
3.40 | radio-box%
3.41 | selectable-menu-item<%>
3.42 | separator-menu-item%
3.43 | scroll-event%
3.44 | slider%
3.45 | subarea<%>
3.46 | subwindow<%>
3.47 | tab-panel%
3.48 | text-field%
3.49 | timer%
3.50 | top-level-window<%>
3.51 | vertical-pane%
3.52 | vertical-panel%
3.53 | window<%>

On this page:

append
clear
delete
find-string
get-number
get-selection
get-string
get-string-selection
set-selection
set-string-selection

Inherited methods:
from control<%>
command
from subwindow<%>
reparent
from window<%>
accept-drop-files
client->screen
enable
focus
get-client-handle
get-client-size
get-cursor
get-handle
get-height
get-label
get-plain-label
get-size
get-width
get-x
get-y
has-focus?
is-enabled?
is-shown?
on-drop-file
on-focus
on-move
on-size
on-subwindow-char
on-subwindow-event
on-subwindow-focus
on-superwindow-enable
on-superwindow-show
popup-menu
refresh
screen->client
set-cursor
set-label
show
warp-pointer
from area<%>
get-graphical-min-size
get-parent
get-top-level-window
min-height
min-width
stretchable-height
stretchable-width
from subarea<%>
horiz-margin
vert-margin

top ← prev up next →

interface list-control<%> : interface?
implements: | control<%>

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.

> method (send a-list-control append item) → void?
> item : label-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).

> method (send a-list-control clear) → void?

Removes all user-selectable items from the control.

> method (send a-list-control delete n) → void?
> n : exact-nonnegative-integer?

Deletes the item indexed by n (where items are indexed from 0). If n is equal to or larger than the number of items in the control, an exn:fail:contract exception is raised.

Selected items that are not deleted remain selected, and no other items are selected.

> method (send a-list-control find-string s)
> → (or/c exact-nonnegative-integer? #f)
> 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 (where items are indexed from 0).

> method (send a-list-control get-number) → exact-nonnegative-integer?

Returns the number of user-selectable items in the control (which is also one more than the greatest index in the list control).

> method (send a-list-control get-selection)
> → (or/c exact-nonnegative-integer? #f)

Returns the index of the currently selected item (where 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.

> method (send a-list-control get-string n)
> → (and/c immutable? label-string?)
> n : exact-nonnegative-integer?

Returns the item for the given index (where 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.

> method (send a-list-control get-string-selection)
> → (or/c (and/c immutable? label-string?) #f)

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.

> method (send a-list-control set-selection n) → void?
> n : exact-nonnegative-integer?

Selects the item specified by the given index (where 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 control callback procedure (provided as an initialization argument) to monitor selection changes.

> method (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 control callback procedure (provided as an initialization argument) to monitor selection changes.

top ← prev up next →