Specifications

67
CHAPTER 7
Menu Commands
Menu commands make menus more flexible and dynamic. As with regular commands, menu
commands can be used to perform almost any kind of edit to the current document, other open
documents, or any HTML document on a local drive. The Menu Commands API expands the
regular command API to accomplish several tasks that are related to displaying and calling the
command from the menu system.
Note: Because menu commands are directly related to the menu system in Dreamweaver, you should read
“Customizing Dreamweaver,” in Using Dreamweaver before continuing in this chapter.
Menu commands are HTML files that are referenced in the file attribute of a menuitem tag in
the
menus.xml file. The BODY of a Menu Commands file can contain an HTML form that
accepts options for the command (for example, how a table should be sorted and by which
column). The
HEAD of a Menu Commands file contains JavaScript functions that process form
input from the
BODY and control the edits that are made to the users document.
Menu commands are stored in the Configuration/Menus folder inside the Dreamweaver
application folder.
Note: If you add custom menu commands to Dreamweaver, add them at the top level of the Menus folder or create
a subfolder. The MM folder is reserved for the menu commands that come with Dreamweaver.
How menu commands work
When the user clicks a menu with a menu item that contains a menu command, the following
events occur:
1 If any menuitem tag in the menu contains the dynamic attribute, Dreamweaver calls the
getDynamicContent() function in the associated Menu Commands file to populate the menu.
2 Dreamweaver calls the canAcceptCommand() function in each Menu Commands file that is
referenced in the menu to check whether the command is appropriate for the selection.
If canAcceptCommand() returns false, the menu item is dimmed.
If canAcceptCommand() returns true or is not defined, Dreamweaver calls the
isCommandChecked() function to determine whether to display a check mark next to the
menu item. If
isCommandChecked() is not defined, no check mark appears.
3 Dreamweaver calls the setMenuText() function to determine the text that should appear in
the menu.
If
setMenuText() is not defined, Dreamweaver uses the text that is specified in the menuitem
tag.
4 The user selects an item from the menu.