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

NextPrevUpTopContentsIndex

8.12 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)
                      (string-append
                       "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
                             :items 
                             '("zebra" "dog" "parrot")
                             :selection-callback
                             'popup-animal-menu))

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 (Unix version) - 3 Aug 2017

NextPrevUpTopContentsIndex