Generates the items for the menu associated with a pane.
capi
pane-popup-menu-items pane interface => items
pane⇩ |
A pane in interface interface. |
interface⇩ |
An interface. |
items⇩ |
The generic function pane-popup-menu-items
generates the items for the menu associated with the pane pane within the interface interface. 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.
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))
This is a further example:
(example-edit-file "capi/elements/pane-popup-menu-items")
CAPI User Guide and Reference Manual (Macintosh version) - 01 Dec 2021 19:31:27