menu-object is the superclass of all menu objects, and provides functionality for handling generic aspects of menus, menu components and menu items.
Callback before the menu appears.
Returns true if the menu is enabled.
The object is enabled if the slot is non-nil.
The selection callback for the object.
A function to return data for the callback.
If non-nil, specifies the argument to the setup callbacks (listed below) that are used to set up the
The title for the object.
A setup callback which returns the title for the object, and optionally a mnemonic for the title.
The simplest way to give a title to a
menu-object is to just supply a
string, and this will then appear as the title of the object.
can be provided which will be called when the menu is about to appear and which should return the title to use. By default
is called on the interface of the
menu-object, but this argument can be changed by passing the initarg
To specify a mnemonic in the title returned by
return the mnemonic as a second value. This value is interpreted in the same way as the
argument for menu.
When the menu object is about to appear on the screen, the CAPI does the following:
The setup callback
(if there is one) is called and the result is used to set the items, for menu and menu-component. The argument passed to
is the same as for the other setup callbacks (see below).
(if there is one) is called and can make arbitrary changes to that object. The
is always called with the menu object, regardless of the value of
The other setup callbacks are called to set up the selection, enabled state and title. These setup callbacks include
for all titled-menu-objects. The additional setup callbacks for menu-component are
. menu-item has the additional setup callback
nil, which means that each of the setup callbacks is called on the interface of the
is non-nil, then it is passed (instead of the interface) as the argument to each of the setup callbacks.
The menu containing the object appears with all of the changes made.
is a short-hand means of creating an
which checks the value of a slot in the menu object's interface.
The enabled state of a
menu-object is computed each time the menu is displayed, using
. Therefore the accessor
menu-object-enabled is only useful as a reader.
argument is placed in the
slots unless these are given explicitly, and so will get called when the menu object is selected or deselected.
is a function that is called with no arguments and the value it returns is used as the data to the callbacks.
should not display a dialog or do anything that may cause the system to hang. In general this means interacting with anything outside the Lisp image, including files, databases and so on.
The subclass titled-menu-object is retained only for backward compatibility.
:text "Press Me"
:enabled-function #'(lambda (item)
(eq (random 2)
The next example illustrates the use of
initialize-instance method adds to the "Some Numbers" menu a sub-menu that lists the selected items in the list-panel. By using
in this menu, the setup callbacks (in this case
) are called directly on the list-panel.
Note that, while this example uses a CAPI object as the
, any object of any type can be used.
(capi:define-interface my-interface ()
:items '(1 2 3 4 5 6 7 8 9 0)
:visible-min-height '(character 10)))
(defmethod initialize-instance :after
((self my-interface) &key)
(with-slots (a-menu list-panel) self
(setf (capi:menu-items a-menu)
(capi:display (make-instance 'my-interface))
CAPI User Guide and Reference Manual (Windows version) - 25 Feb 2015