Macromedia dreamweaver 8-extending dreamweaver User Manual

Page of 504
200
Menus and Menu Commands
In this command, the 
receiveArguments()
 function processes the arguments and executes 
the command. More complex menu commands might call different functions to execute the 
command. For example, the following code checks whether the first argument is 
"foo"
; if it 
is, it calls the 
doOperationX()
 function and passes it the second argument. If the first 
argument is 
"bar"
, it calls the 
doOperationY()
 function and passes it the second argument. 
The 
doOperationX()
 or 
doOperationY()
 function is responsible for executing the 
command.
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.”