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.
Содержание DREAMWEAVER 8-EXTENDING DREAMWEAVER
Страница 1: ...Extending Dreamweaver...
Страница 8: ...8 Contents...
Страница 14: ...14 Introduction...
Страница 16: ......
Страница 54: ...54 Customizing Dreamweaver...
Страница 96: ...96 Customizing Code View...
Страница 98: ......
Страница 110: ...110 Extending Dreamweaver...
Страница 138: ......
Страница 166: ...166 Insert Bar Objects...
Страница 180: ...180 Commands...
Страница 248: ...248 Toolbars...
Страница 260: ...260 Reports...
Страница 278: ...278 Tag Libraries and Editors...
Страница 288: ...288 Property Inspectors...
Страница 378: ...378 Server Behaviors...
Страница 398: ...398 Data Sources...
Страница 432: ...432 Server Models...
Страница 456: ...456 Data Translators...
Страница 482: ......
Страница 492: ...492 The Shared Folder...