
168 Commands
4. Dreamweaver calls the commandButtons() function, if defined, to determine which
buttons appear on the right side of the Options dialog box and what code should execute
when the user clicks the buttons.
5. Dreamweaver scans the command file for a FORM tag. If a form exists, Dreamweaver calls
the
windowDimensions() function, which sizes the Options dialog box that contains the
BODY elements of the file. If the windowDimensions() function is not defined,
Dreamweaver automatically sizes the dialog box.
6. If the command file’s BODY tag contains an onLoad handler, Dreamweaver executes it
(whether or not a dialog box appears). If no dialog box appears, the remaining steps do not
occur.
7. The user selects options for the command. Dreamweaver executes event handlers that are
associated with the fields as the user encounters them.
8. The user clicks one of the buttons that is defined by the commandButtons() function.
9. Dreamweaver executes the associated code. The dialog box remains visible until one of the
scripts in the command calls the
window.close() function.
Adding commands to the Commands
menu
Dreamweaver automatically adds any files that are inside the Configuration/Commands
folder to the bottom of the Commands menu. To prevent a command from appearing in the
Commands menu, insert the following comment on the first line of the file:
<!-- MENU-LOCATION=NONE -->
When this line is present, Dreamweaver does not create a menu item for the file, and you
must call
dw.runCommand() to execute the command.
A simple command example
This simple extension adds an item to the Commands menu and lets you convert selected text
in your document to either uppercase or lowercase. When you click the menu item, it
activates a three-button interface that lets you submit your choice.
You create this extension by performing the following steps:
■ Creating the UI
■ Writing the JavaScript code
■ Testing the extension
Comentarios a estos manuales