NextPrevUpTopContentsIndex

pane-popup-menu-items

Generic Function
Summary

Generates the items for the menu associated with a pane.

Package

capi

Signature

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

Arguments

pane

A pane in interface interface .

interface

An interface.

Values

items

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

Description

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 .

Note: 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 descendent menu-objects, must be constructed each time that pane-popup-menu-items is called, so that no two menus share any menu item.

Note: 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 .

Example

The methods below specialized on interface class eg:

  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 eg ()
  ()
  (: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 eg))
  (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 eg))
  (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 'eg))
See also

make-pane-popup-menu


LispWorks CAPI Reference Manual - 25 Jul 2006

NextPrevUpTopContentsIndex