3.10 choice%
Implements: list-control<%>
A choice item allows the user to select one string item from a pop-up list of items. Unlike a list box, only the currently selection is visible until the user pops-up the menu of choices.
Whenever the selection of a choice item is changed by the user, the choice item's callback procedure is invoked. A callback procedure is provided as an initialization argument when each choice item is created.
See also
list-box%.
(->newchoice% (label_) (choices_) (parent_) [(callback_)] [(style_)] [(selection_)] [(font_)] [(enabled_)] [(vert-margin_)] [(horiz-margin_)] [(min-width_)] [(min-height_)] [(stretchable-width_)] [(stretchable-height_)])choice%object
label: string (up to 200 characters) or#f
choices: list of strings (up to 200 characters each)
parent:frame%,dialog%,panel%, orpane%object
callback=: procedure of two arguments: a(lambda(ce) (void))choice%object and acontrol-event%object
style=null: list of symbols in'(vertical-label horizontal-label deleted)
selection=0: exact non-negative integer
font=:normal-control-fontfont%object
enabled=#t: boolean
vert-margin=2: exact integer in [0, 1000]
horiz-margin=2: exact integer in [0, 1000]
min-width=graphical minimum width: exact integer in [0, 10000]
min-height=graphical minimum height: exact integer in [0, 10000]
stretchable-width=#f: boolean
stretchable-height=#f: booleanCreates a choice item. If
labelis a string, it is used as the label for the choice item.If an ampersand (``&'') occurs in
label, it is specially parsed; under Windows and X, the character following an ampersand is underlined in the displayed control to indicate a keyboard mnemonic. (Under Mac OS X, mnemonic underlines are not shown.) The underlined mnemonic character must be a letter or a digit. The user can move the keyboard focus to the choice item by typing the mnemonic when the control's top-level-window contains the keyboard focus. The user must also hold down the Meta or Alt key if the keyboard focus is currently in a control that handles normal alphanumeric input. The ampersand itself is removed fromlabelbefore it is displayed for the control; a double-ampersand inlabelis converted to a single ampersand (with no mnemonic underlining). Under Mac OS X, a parenthesized mnemonic character is removed (along with any surrounding space) before the label is displayed, since a parenthesized mnemonic is often used for non-Roman languages. Finally, any text after a tab character is removed on all platforms. Mnemonic keyboard events are handled byon-traverse-char(but not under Mac OS X).The
choiceslist specifies the initial list of user-selectable items for the control. The initial set of choices determines the control's minimum graphical width (see Geometry Management for more information).The
callbackprocedure is called (with the event type'choice) when the user selects a choice item (or re-selects the currently selected item).If
styleincludes'vertical-label, then the choice item is created with a label above the control; ifstyledoes not include'vertical-label(and optionally includes'horizontal-label), then the label is created to the left of the choice item. Ifstyleincludes'deleted, then the choice item is created as hidden, and it does not affect its parent's geometry; the choice item can be made active later by callingparent'sadd-childmethod.By default, the first choice (if any) is initially selected. If
selectionis positive, it is passed toset-selectionto set the initial choice selection. Althoughselectionnormally must be less than the length ofchoices, it can be0whenchoicesis empty.The
fontargument determines the font for the control. For information about theenabledargument, seewindow<%>. For information about thehoriz-marginandvert-marginarguments, seesubarea<%>. For information about themin-width,min-height,stretchable-width, andstretchable-heightarguments, seearea<%>.
All Methods
accept-drop-files from window<%>
append from list-control<%>
clear from list-control<%>
client->screen from window<%>
command from control<%>
enable from window<%>
find-string from list-control<%>
focus from window<%>
get-client-size from window<%>
get-cursor from window<%>
get-font from control<%>
get-graphical-min-size from area<%>
get-handle from window<%>
get-height from window<%>
get-label from window<%>
get-number from list-control<%>
get-parent from area<%>
get-plain-label from window<%>
get-selection from list-control<%>
get-size from window<%>
get-string from list-control<%>
get-string-selection from list-control<%>
get-top-level-window from area<%>
get-width from window<%>
get-x from window<%>
get-y from window<%>
has-focus? from window<%>
horiz-margin from subarea<%>
is-enabled? from window<%>
is-shown? from window<%>
min-height from area<%>
min-width from area<%>
on-drop-file from window<%>
on-focus from window<%>
on-move from window<%>
on-size from window<%>
on-subwindow-char from window<%>
on-subwindow-event from window<%>
on-superwindow-enable from window<%>
on-superwindow-show from window<%>
popup-menu from window<%>
refresh from window<%>
screen->client from window<%>
set-cursor from window<%>
set-label from window<%>
set-selection from list-control<%>
set-string-selection from list-control<%>
show from window<%>
stretchable-height from area<%>
stretchable-width from area<%>
vert-margin from subarea<%>