All Manuals > CAPI User Guide and Reference Manual > 8 Creating Menus

8.13 Displaying menus programmatically

You can programmatically display a menu by using display-popup-menu (which is used internally to raise the context menu). The menu that display-popup-menu displays can be any properly constructed menu object, for example:

(defun popup-animal-menu (animal interface)
  (let* ((items (list (string-append
                       "Get a picture of a " animal)
                       "Send a postcard to " animal)))
         (menu (make-instance 'capi:menu :items items)))
    (capi:display-popup-menu menu :owner interface)))
(capi:contain (make-instance 'capi:list-panel
                             '("zebra" "dog" "parrot")

Click on an item to see the menu.

You can use popup-menu-force-popdown to force a popup menu down (that is, make it disappear). This is useful for writing scripts that emulate user interactions.

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