Adobe 38040334 - Dreamweaver CS3 User Manual page 155

Extending dreamweaver
Hide thumbs Also See for 38040334 - Dreamweaver CS3:
Table of Contents

Advertisement

<menuitem name="MyUndo" key="Cmd+Z" file="Menus/MyMenu.htm" arguments="'undo'"
id="MyMenu_Edit_Undo" />
<menuitem name="MyRedo" key="Cmd+Y" file="Menus/MyMenu.htm" arguments="'redo'"
id="MyMenu_Edit_Redo" />
</menu>
The
attribute defines keyboard shortcut keys that the user can type to invoke the menu item. The
key
specifies the name of the command file that Dreamweaver executes when Dreamweaver invokes the menu item. The
value of the
attribute defines the arguments that Dreamweaver will pass when it calls the
arguments
function.
receiveArguments()
The following figure shows these menu items:
Writing the JavaScript code
When the user selects either Undo or Redo on the MyMenu menu, Dreamweaver calls the MyMenu.htm command
file, which is specified by the
Dreamweaver Configuration/Menus folder and add the three menu command API functions,
,
canAcceptCommand()
receiveArguments()
Undo and Redo menu items
canAcceptCommand()
Dreamweaver calls the
canAcceptCommand()
whether it should be enabled or disabled. In the MyMenu.htm file, the
value of
to determine whether Dreamweaver is processing a Redo menu item or an Undo menu item.
arguments[0]
If the argument is
, the
"undo"
the returned value, which is either
function calls the enabler function
function returns the value
canAcceptCommand()
function. The following example shows the code for the
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;
}
attribute of the
file
menuitem
, and
setMenuText()
The following sections describe these functions.
.
function for each menu item in the MyMenu menu to determine
function calls the enabler function
canAcceptCommand()
or
. Likewise, if the argument is
true
false
and returns its value to Dreamweaver. If the
dw.canRedo()
false
tag. Create the MyMenu.htm command file in the
, to implement the logic associated with the
canAcceptCommand()
"redo"
, Dreamweaver dims the menu item for which it called the
function:
canAcceptCommand()
DREAMWEAVER CS3
Extending Dreamweaver
attribute
file
function checks the
and returns
dw.canUndo()
, the
canAcceptCommand()
149

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dreamweaver cs3

Table of Contents