A Dynamic Menu Example - Adobe 38040334 - Dreamweaver CS3 User Manual

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

Advertisement

The
function looks like the following example code:
setMenuText()
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 Dream-
weaver Configuration/Menus folder or a subfolder that you create. The location of the file must agree with the
location that you specified in the
or reload extensions. For information on how to reload extensions, see "Reloading extensions" on page 74.
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 "How menu commands work" on page 147.

A dynamic menu example

This example implements the Dreamweaver Preview In Browser submenu that displays a list of available browsers.
The example also opens the current file, or the selected files in the Site panel, in the user-specified browser. Imple-
menting this dynamic menu consists of the following steps:
• "Creating the dynamic menu items" on page 151
• "Writing the JavaScript code" on page 152
Creating the dynamic menu items
The following menu tags in the menus.xml file define the Preview In Browser submenu of the File menu:
<menu name="_Preview in Browser" id="DWMenu_File_PIB">
<menuitem dynamic name="No Browsers Selected"
file="Menus/MM/PIB_Dynamic.htm" arguments="'No Browsers'"
id="DWMenu_File_PIB_Default" />
<separator />
<menuitem name="_Edit Browser List..." enabled="true"
command="dw.editBrowserList()" id="DWMenu_File_PIB_EditBrowserList" />
</menu>
tag. To make it accessible to Dreamweaver, either restart Dreamweaver
menuitem
DREAMWEAVER CS3
151
Extending Dreamweaver

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dreamweaver cs3

Table of Contents