1 CAPI Reference Entries

menu

Class

Summary

The classmenu creates a menu for an interface when specified as part of the menu bar (or as a submenu of a menu on the menu bar).

Superclasses

element
titled-menu-object

Slots

items
The items to appear in the menu.

items-function

A function to dynamically compute the items.

Accessors

menu-items

Description

A menu has a title, and has items appearing in it, where an item can be either a menu item, a menu component or another menu.

The simplest way of providing items to a menu is to pass them using theitem slot, but if you need to compute the items dynamically you should provide anitems-function. This function gets called with the menu, and it should return a list of menu items for the new menu. This function is called before thepopup-callback and theenabled-function which means that they can affect the new items.

When debugging a menu, it may be useful to pop up a window containing a menu with the minimum of fuss. The functioncontain will do just that for you.

Examples

(capi:contain (make-instance 'capi:menu
                             :title "Test"
                             :items '(:red :green :blue)))
(capi:contain (make-instance 'capi:menu
                             :title "Test"
                             :items '(:red :green :blue)
                             :print-function
                              'string-capitalize))

(capi:contain (make-instance 'capi:menu :title "Test" :items '(:red :green :blue) :print-function 'string-capitalize :callback #'(lambda (data interface) (capi:display-message "Pressed ~S" data))))

Here is an example of how to add submenus to a menu

(setq submenu (make-instance 'capi:menu
                             :title "Submenu..."
                             :items '(1 2 3)))

(capi:contain (make-instance 'capi:menu :title "Test" :items (list submenu)))

Finally, here is an example showing how to use theitems-function:

(capi:contain (make-instance
               'capi:menu
               :title "Test"
               :items-function #'(lambda (menu)
                                   (loop for i below 8
                                    collect (random 10)
                                   ))))

Example File

capi/elements/menus.lisp

See Also

menu-component
menu-item
menu-object
contain


CAPI Reference Manual, Liquid Common Lisp Version 5.0 - 3 OCT 1997

Generated with Harlequin WebMaker