Next Previous Up Top Contents Index

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)
                                   ))))

See also

menu-component
menu-item
menu-object
contain

LispWorks CAPI Reference Manual - 17 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker