User Guide

156 Chapter 8: Menus and Menu Commands
9 The user selects options in the dialog box. Dreamweaver executes event handlers that are
associated with the fields as the user encounters them.
10 The user clicks one of the buttons that are defined by the commandButtons() function.
11 Dreamweaver executes the code that is associated with the clicked button.
12 The dialog box remains visible until one of the scripts in the Menu Commands calls the
window.close() function.
The Menu Commands API
The custom functions in the Menu Commands API are not required.
canAcceptCommand()
Description
Determines whether the menu item is active or dimmed.
Arguments
{arg1}, {arg2},...{argN}}
If it is a dynamic menu item, the unique ID that the getDynamicContents() function
specifies is the only argument. Otherwise, if the
arguments attribute is defined for a menuitem
tag, the value of that attribute passes to the
canAcceptCommand() function (and to the
isCommandChecked(), receiveArguments(), and setMenuText() functions) as one or more
arguments. The
arguments attribute is useful for distinguishing between two menu items that
call the same menu command.
Note: The arguments attribute is ignored for dynamic menu items.
Returns
Dreamweaver expects a Boolean value: true if the item should be enabled; false otherwise.
commandButtons()
Description
Defines the buttons that appear on the right side of the Options dialog box and their behavior
when they are clicked. If this function is not defined, no buttons appear, and the
BODY section of
the Menu Commands file expands to fill the entire dialog box.
Arguments
None.
Returns
Dreamweaver expects an array that contains an even number of elements. The first element is a
string that contains the label for the topmost button. The second element is a string of JavaScript
code that defines the behavior of the topmost button when it is clicked. The remaining elements
define additional buttons in the same manner.