Placing the command file in the menu folder – Adobe Extending Dreamweaver CS4 User Manual
Page 161
155
EXTENDING DREAMWEAVER CS4
Menus and menu commands
function receiveArguments(){
if (arguments.length != 2) return;
var whatToDo = arguments[0];
if (whatToDo == "foo"){
doOperationX(arguments[1]);
}else if (whatToDo == "bar"){
doOperationX(arguments[1]);
}
}
setMenuText()
Dreamweaver calls the
setMenuText()
function to determine what text appears for the menu item. If you do not
define the
setMenuText()
function, Dreamweaver uses the text that you specified in the
name
attribute of the
menuitem
tag.
The
setMenuText()
function checks the value of the argument that Dreamweaver passes,
arguments[0]
. If the value
of the argument is
"undo"
, Dreamweaver calls the
dw.getUndoText()
function; if it is
"redo"
, Dreamweaver calls
dw.getRedoText()
. The
dw.getUndoText()
function returns text that specifies the operation that Dreamweaver will
undo. For example, if the user executes multiple Redo operations,
dw.getUndoText()
could return the menu text
“Undo Edit Source.” Likewise, the
dw.getRedoText()
function returns text that specifies the operation that
Dreamweaver will redo. If the user executes multiple Undo operations, the
dw.RedoText()
function could return the
menu text “Redo Edit Source.”
The
setMenuText()
function looks like the following example code:
function setMenuText()
{
if (arguments.length != 1) return "";
var whatToDo = arguments[0];
if (whatToDo == "undo")
return dw.getUndoText();
else if (whatToDo == "redo")
return dw.getRedoText();
else return "";
}
Placing the command file in the Menu folder
To implement the menu Undo and Redo menu items, you must save the
MyMenu.htm
command file in the
Dreamweaver Configuration/Menus folder or a subfolder that you create. The location of the file must agree with the
location that you specified in the
menuitem
tag. To make it accessible to Dreamweaver, either restart Dreamweaver or
reload extensions. For information on how to reload extensions, see “
To run the menu commands, select the menu item when it is enabled. Dreamweaver will invoke the functions in the
command file, as described in “