170
Commands
The contents of the
Title
tag,
Make Uppercase or Lowercase
, appears in the top bar of
the dialog box. Within the form, a table with two cells controls the layout of the elements.
Within the table cells are the two radio buttons, Uppercase and Lowercase. The Uppercase
button has the
checked
attribute, making it the default selection and ensuring that the user
must either select one of the two buttons or cancel the command.
The form looks like the following figure.
The
commandButtons()
function supplies the OK and Cancel buttons that let the user
submit the choice or cancel the operation.
Writing the JavaScript code
The following example consists of two extension API functions,
canAcceptCommand()
and
commandButtons()
, which Dreamweaver calls, and one user-defined function,
changeCase()
, which is called from the
commandButtons()
function.
In this example, you will write JavaScript to perform the following tasks:
■
Determining whether the command should be enabled or dimmed
■
Linking functions to the OK and Cancel buttons
■
Letting the user specify uppercase or lowercase
Determining whether the command should be enabled or
dimmed
The first task in creating a command is to determine when the item should be active and
when it should be dimmed. When a user clicks the Commands menu, Dreamweaver calls the
canAcceptCommand()
function for each menu item to determine whether it should be
enabled. If
canAcceptCommand()
returns the value
true
, Dreamweaver displays the menu
item text as active or enabled. If
canAcceptCommand()
returns the value
false
, Dreamweaver
dims the menu item. In this example, the menu item is active when the user has selected text
in the document.
Summary of Contents for DREAMWEAVER 8-EXTENDING DREAMWEAVER
Page 1: ...Extending Dreamweaver...
Page 8: ...8 Contents...
Page 14: ...14 Introduction...
Page 16: ......
Page 54: ...54 Customizing Dreamweaver...
Page 96: ...96 Customizing Code View...
Page 98: ......
Page 110: ...110 Extending Dreamweaver...
Page 138: ......
Page 166: ...166 Insert Bar Objects...
Page 180: ...180 Commands...
Page 248: ...248 Toolbars...
Page 260: ...260 Reports...
Page 278: ...278 Tag Libraries and Editors...
Page 288: ...288 Property Inspectors...
Page 378: ...378 Server Behaviors...
Page 398: ...398 Data Sources...
Page 432: ...432 Server Models...
Page 456: ...456 Data Translators...
Page 482: ......
Page 492: ...492 The Shared Folder...