All Manuals > CAPI User Guide and Reference Manual

8 Creating Menus

You can create menus for an application using the menu class. For more control you can also use menu-component and menu-item.

menu, menu-component and menu-item all inherit from the callbacks class, which defines callbacks that are called when the user selects an item in the menu. They also inherit from the menu-object class, which adds some menu-specific callback functionality, title and enabling.

You should make sure you have defined the test-callback and hello functions before attempting any of the examples in this chapter. Their definitions are repeated here for convenience.

(defun test-callback (data interface)
  (display-message "Data ~S in interface ~S" 
                   data interface))
(defun hello (data interface)
  (declare (ignore data interface)) 
  (display-message "Hello World"))

The menus in the menu bar of a window are defined by the :menu-bar of the interface. See define-interface, the interface initarg :menu-bar-items, and 11.3.1 Adding menus. The macro define-interface allows you to define menus by specifying the arguments that you would pass to cl:make-instance if you made them explicitly. The actual menus in the menu bar have the properties described in this chapter.

8.1 Creating a menu

8.2 Presenting menus

8.3 Grouping menu items together

8.4 Creating individual menu items

8.5 The CAPI menu hierarchy

8.6 Mnemonics in menus

8.7 Accelerators in menus

8.8 Alternative menu items

8.9 Disabling menu items

8.10 Menus with images

8.11 The Edit menu on Cocoa

8.12 Popup menus for panes

8.13 Displaying menus programmatically

8.14 The Application menu

CAPI User Guide and Reference Manual (Macintosh version) - 01 Dec 2021 19:31:20