Adding Commands To The Commands Menu; A Simple Command Example - Adobe 38040334 - Dreamweaver CS3 User Manual

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

Advertisement

Dreamweaver calls the
4
commandButtons()
side of the Options dialog box and what code should execute when the user clicks the buttons.
Dreamweaver scans the command file for a
5
function, which sizes the Options dialog box that contains the body elements of the file. If
windowDimensions()
the
windowDimensions()
If the command file's
6
body
appears). If no dialog box appears, the remaining steps do not occur.
The user selects options for the command. Dreamweaver executes event handlers that are associated with the
7
fields as the user encounters them.
8
The user clicks one of the buttons that is defined by the
Dreamweaver executes the associated code. The dialog box remains visible until one of the scripts in the
9
command calls the
window.close()

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
to execute the command.
dw.runCommand()

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" on page 127
• "Writing the JavaScript code" on page 128
• "Testing the extension" on page 133
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.
Creating the UI
The UI is a form that contains two radio buttons that let the user select uppercase or lowercase.
To create the user interface:
1
Create a blank file.
function, if defined, to determine which buttons appear on the right
tag. If a form exists, Dreamweaver calls the
form
function is not defined, Dreamweaver automatically sizes the dialog box.
tag contains an
handler, Dreamweaver executes it (whether or not a dialog box
onLoad
function.
function.
commandButtons()
DREAMWEAVER CS3
127
Extending Dreamweaver

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dreamweaver cs3

Table of Contents