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