Some elements of a window interface contain collections of items, for example rows of buttons, lists of filenames, and groups of menu items. Such elements are known in the CAPI as collections .
In most collections, items may be selected by the user -- for example, a row of buttons. Collections whose items can be selected are known as choices . Each button in a row of buttons is either checked or unchecked, showing something about the application's state -- perhaps that color graphics are switched on and sound is switched off. This selection state came about as the result of a choice the user made when running the application, or default choices made by the application itself.
The CAPI provides a convenient way of producing groups of items from which collections and choices can be made. The abstract class
collection
provides a means of specifying a group of items. The subclass
choice
provides groups of selectable items, where you may specify what initial state they are in, and what happens when the selection is changed. Subclasses of
collection
and
choice
used for producing particular kinds of grouped elements are described in the sections that follow.
All the choices described in this chapter can be given a print function via the
:print-function
keyword. This allows you to control the way in which items in the element are displayed. For example, passing the argument
'string-capitalize
to
:print-function
would capitalize the initial letters of all the words of text that an instance of a choice displays.
Some of the examples in this chapter require the functions
test-callback
and
hello
which were introduced in Creating Common Windows.
CAPI User Guide (Macintosh version) - 30 Aug 2011