User Guide
162 Chapter 8: Menus and Menu Commands
canAcceptCommand()
Dreamweaver calls the
canAcceptCommand() function for each menu item in the MyMenu menu
to determine whether it should be enabled or disabled. In the MyMenu.htm file, the
canAcceptCommand() function checks the value of arguments[0] to determine whether
Dreamweaver is processing a Redo menu item or an Undo menu item. If the argument is
"undo",
the
canAcceptCommand() function calls the enabler function dw.canUndo() and returns the
returned value, which is either
true or false. Likewise, if the argument is "redo", the
canAcceptCommand() function calls the enabler function dw.canRedo(), and returns its value to
Dreamweaver. If the
canAcceptCommand() function returns the value false, Dreamweaver dims
the menu item for which it called the function. The following example shows the code for the
canAcceptCommand() function:
function canAcceptCommand()
{
var selarray;
if (arguments.length != 1) return false;
var bResult = false;
var whatToDo = arguments[0];
if (whatToDo == "undo")
{
bResult = dw.canUndo();
}
else if (whatToDo == "redo")
{
bResult = dw.canRedo();
}
return bResult;
}
receiveArguments()
Dreamweaver calls the
receiveArguments() function to process any arguments that you defined
for the
menuitem tag. For the Undo and Redo menu items, the receiveArguments() function
calls either the
dw.undo() function or the dw.redo() function, depending on whether the value
of the argument,
arguments[0], is "undo" or "redo". The dw.undo() function undoes the
previous step that the user performed in the document window, dialog box, or panel that has
focus. The
dw.redo() function redoes the last operation that was undone.
The
receiveArguments() function looks like the following example code:
function receiveArguments()
{
if (arguments.length != 1) return;
var whatToDo = arguments[0];
if (whatToDo == "undo")
{
dw.undo();
}
else if (whatToDo == "redo")
{
dw.redo();
}
}