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

NextPrevUpTopContentsIndex

8.9 Disabling menu items

A function can be specified via the :enabled-function initarg (inherited from menu-object), that determines whether or not the menu, menu item, or menu component is enabled. By default, a menu object is always enabled.

Consider the following example:

(defvar *on* nil)
 
(contain
 (make-instance 'menu
                :items
                (list 
                 (make-instance 
                 'menu-item
                 :title "Foo"
                 :enabled-function 
                 #'(lambda (menu) *on*))
                (make-instance 
                 'menu-item
                 :title "Bar"))))

Figure 8.7 A menu with a disabled menu item

Changing the value of *on* between t and nil in the Listener, using setq, results in the menu item changing between the enabled and disabled states.

8.9.1 Dialogs and disabled menu items

By default, items in the menu bar menus and sub-menus are disabled while a dialog is on the screen on top of the active window. You can override this by passing a suitable value for the menu-item initarg :enabled-function-for-dialog.


CAPI User Guide and Reference Manual (Windows version) - 3 Aug 2017

NextPrevUpTopContentsIndex