DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Configuring Desktop menus

Disabling menu commands

A menu command can be disabled, to indicate to the user that it is not applicable in the current situation.

It is better to disable an inapplicable menu command than to allow the user to choose it and then display an error dialog box.

To disable a menu command, include an enable_if clause in the menu_item clause defining the command. This has the form:

   enable_if { script }

In this example, script is a script that is executed when the menu is displayed. If it returns a ``true'' status the command is enabled; otherwise it is disabled.

For example, the following menu command is only enabled if at least one icon has been selected:

   menu: DesktopMyMenu
   {
     menu_item
     {
       title=MyCommand;
       enable_if
       {
         sels=`(query selections `(query thread_info -i $thread_name(2)))
         -gt $#sels 0
       }
       select_action
       {
         ...
       }
     }
   }

See also:



Next topic: Removing menus
Previous topic: Pop-up menus

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003