Adding commands to the commands menu, A simple command example, Create the user interface – Adobe Extending Dreamweaver CS4 User Manual
Page 138
132
EXTENDING DREAMWEAVER CS4
Commands
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:
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.
To create this extension, you create the UI, write the JavaScript code, and test the extension.
This example creates two files in the Commands folder: Change Case.htm, which contains the UI, and Change Case.js,
which contains the JavaScript code. If you prefer, you can create only the Change Case.htm file and put the JavaScript
code in the head section.
Create the user interface
The user interface is a form that contains two options that let the user select uppercase or lowercase.
1
Create a blank file.
2
Add the following code to the file to create the form: