All Manuals > CAPI User Guide and Reference Manual > 21 CAPI Reference Entries



Generic Function

Generates the items for the menu associated with a pane.




pane-popup-menu-items pane interface => items



A pane in interface interface .


An interface.



A list in which each element is a menu-item, menu-component or menu.


The generic function pane-popup-menu-items generates the items for the menu associated with the pane pane . The default method of make-pane-popup-menu calls pane-popup-menu-items to find the items for the menu. If pane-popup-menu-items returns nil, then make-pane-popup-menu returns nil.

To specify items for menus associated with panes in your interfaces, define pane-popup-menu-items methods specialized on your interface class.

For most supplied CAPI pane classes, the system method returns nil. The exceptions are editor-pane and graph-pane. To inherit the items from the system method (or other more general method), call call-next-method.

  1. pane-popup-menu-items is not supported for text panes on Cocoa such as rich-text-pane.
  2. pane-popup-menu-items is intended to allow multiple calls on the same pane, to generate menus in different places (as in the example in make-pane-popup-menu). Therefore the menu-objects that it returns, and their descendant menu-objects, must be constructed each time that pane-popup-menu-items is called, so that no two menus share any menu item.
  3. The items returned by pane-popup-menu-items may specify the arguments for their callbacks, but it is not required. If they do not specify the arguments, then make-pane-popup-menu (by calling make-menu-for-pane) sets up the callbacks such that they are called on the pane pane .

The methods below specialized on interface class edgraph:

  1. Append the items that were returned by the system method in the bottom of the menu for the editor-pane, and
  2. Add them as a sub-menu for the menu of the graph-pane.
(capi:define-interface edgraph ()
   (e1 capi:editor-pane)
   (g1 capi:graph-pane))
   (main-layout capi:column-layout '(e1 g1)))
  (:menu-bar  )
   :visible-min-width 200
   :visible-min-height 300))
(defun my-callback (pane)
  (capi:display-message "Callback on pane ~S." pane))
(defmethod capi:pane-popup-menu-items 
           ((self capi:editor-pane) (interface edgraph))
   (make-instance 'capi:menu-item
                  :title "Item for My Editor Menu."
                  :selection-callback 'my-callback)
(defmethod capi:pane-popup-menu-items
           ((self capi:graph-pane) (interface edgraph))
   (make-instance 'capi:menu-item
                  :title "Item for My Graph Menu."
                  :selection-callback 'my-callback)
   (capi:make-menu-for-pane self (call-next-method) 
                            :title "Default Graph Menu")))
(capi:display (make-instance 'edgraph))

This is a further example:

(example-edit-file "capi/elements/pane-popup-menu-items")
See also

Popup menus for panes

CAPI User Guide and Reference Manual (Unix version) - 25 Feb 2015