6 Creating Menus

6.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. Type the following into a Listener:

(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.

2. Type 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.


CAPI User Guide, Liquid Common Lisp Version 5.0 - 2 OCT 1997

Generated with Harlequin WebMaker