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
.
pane-popup-menu-items
is not supported for text panes on Cocoa such as rich-text-pane.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.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
:
(capi:define-interface edgraph ()
()
(:panes
(e1 capi:editor-pane)
(g1 capi:graph-pane))
(:layouts
(main-layout capi:column-layout '(e1 g1)))
(:menu-bar )
(:default-initargs
: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))
(list*
(make-instance 'capi:menu-item
:title "Item for My Editor Menu."
:selection-callback 'my-callback)
(call-next-method)))
(defmethod capi:pane-popup-menu-items
((self capi:graph-pane) (interface edgraph))
(list
(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))
(example-edit-file "capi/elements/pane-popup-menu-items")
CAPI User Guide and Reference Manual (Unix version) - 25 Feb 2015