A menu item is an individual item in a menu or menu component, and instances of menu-item
are created automatically by define-interface
.
The text displayed in the menu item is the contents of the text slot, or the contents of the title slot, otherwise it is the result of applying the print function to the data.
Callbacks are made in response to a user gesture on a menu item. The callback type, function and data function (see callbacks) are found by looking for a non- nil
value, first in the menu item, then the menu component (if any) and finally the menu. This allows a whole menu to have, for example, callback-type
:data
without having to specify this in each item. Some items could override this by having their callback-type
slot non- nil
if needed.
To specify a mnemonic in the menu item, you can use the initarg :mnemonic
, or the initargs :mnemonic-title
and mnemonic-escape
. These initargs are all interpreted just as in menu.
A menu item should not be used more in more than one place at a time.
(capi:contain (make-instance 'capi:menu-item
:text "Press Me"))
(capi:contain (make-instance 'capi:menu-item
:data :red
:print-function
'string-capitalize))
(capi:contain (make-instance
'capi:menu-item
:data :red
:print-function 'string-capitalize
:callback #'(lambda (data interface)
(capi:display-message
"Pressed ~S"
data))))