All Manuals > CAPI User Guide > 11 Prompting for Input > 11.2 Prompting for values

NextPrevUpTopContentsIndex

11.2.3 Prompting for an item in a list

If you would like the user to select an item from a list of items, the function prompt-with-list should handle the majority of cases. The simplest form just passes a list to the function and expects a single item to be returned.

(prompt-with-list
 '(:red :yellow :blue)
 "Select a color:")

Figure 11.5 A dialog prompting for a selection from a list

You can also specify the interaction style that you would like for your dialog, which can be any of the interactions accepted by a choice. The specification of the interaction style to this choice is made using the keyword argument :interaction :

(prompt-with-list
 '(:red :yellow :blue)
 "Select a color:"
 :interaction :multiple-selection)

By default, the dialog is created using a list-panel to display the items, but the keyword argument :choice-class can be specified with any choice pane. Thus, for instance, you can present a list of buttons.

(prompt-with-list
  '(:red :yellow :blue)
  "Select a color:"
  :interaction :multiple-selection
   :choice-class 'button-panel)

Figure 11.6 Selection from a button panel

Finally, as with any of the prompting functions, you can specify additional arguments to the pane that has been created in the dialog. Thus to create a column of buttons instead of the default row, use:

(prompt-with-list
 '(:red :yellow :blue)
 "Select a color:"
 :interaction :multiple-selection
 :choice-class 'button-panel
 :pane-args
 '(:layout-class column-layout))

Figure 11.7 Selection from a column of buttons

There is a more complex example in

examples/capi/choice/prompt-with-buttons.lisp

CAPI User Guide (Macintosh version) - 30 Aug 2011

NextPrevUpTopContentsIndex