NextPrevUpTopContentsIndex

8.1 Creating a menu

A menu can be created in much the same way as any of the CAPI classes you have already met.

  1. Enter the following into a Listener:
  2. (make-instance 'menu
        :title "Foo"
        :items '("One" "Two" "Three" "Four")
        :callback 'test-callback)
    (make-instance 'interface
        :menu-bar-items (list *))
    (display *)

    This creates a CAPI interface with a menu, Foo , which contains four items. Choosing any of these items displays its arguments. Each item has the callback specified by the :callback keyword.

    A submenu can be created simply by specifying a menu as one of the items of the top-level menu.

  3. Enter the following into a Listener:
(make-instance 'menu
    :title "Bar"
    :items '("One" "Two" "Three" "Four")
    :callback 'test-callback)
(make-instance 'menu
    :title "Baz"
    :items (list 1 2 * 4 5)
    :callback 'test-callback)
(contain *)

This creates an interface which has a menu, called Baz , which itself contains five items. The third item is another menu, Bar , which contains four items. Once again, selecting any item returns its arguments.

Menus can be nested as deeply as required using this method.


LispWorks CAPI User Guide (Windows version) - 14 Jun 2006

NextPrevUpTopContentsIndex