The toolbar command api functions, Canacceptcommand(), The toolbar command – Adobe Extending Dreamweaver CS4 User Manual

Page 191: Api functions

Advertising
background image

185

EXTENDING DREAMWEAVER CS4

Toolbars

<button id="DW_Undo"

image="Toolbars/images/MM/undo.gif"
disabledImage="Toolbars/images/MM/undo_dis.gif"
tooltip="Undo"
file="Menus/MM/Edit_Clipboard.htm"
arguments="'undo'"
update="onEveryIdle"/>

<button id="DW_Redo"

image="Toolbars/images/MM/redo.gif"
disabledImage="Toolbars/images/MM/redo_dis.gif"
tooltip="Redo"
file="Menus/MM/Edit_Clipboard.htm"
arguments="'redo'"
update="onEveryIdle"/>

The toolbar command API functions

In many cases where you specify a script for an attribute, you can also implement the attribute through a JavaScript
function in a command file. This action is necessary when the functions need to take arguments, as in the command
handler for a text box. It is required for pop-up menus and combo boxes.

The command file API for toolbar items is an extension of the menu commands file API, so you can reuse menu
commands files directly as toolbar command files, perhaps with some additional functions that are specific to toolbars.

canAcceptCommand()

Availability
Dreamweaver MX.

Description
Determines whether the toolbar item is enabled. The enabled state is the default condition for an item, so you should
not define this function unless it returns a

false

value in at least one case.

Arguments
For pop-up menus, combo boxes, text boxes, and color pickers, the first argument is the current value within the
control. The

getDynamicContent()

function can optionally attach individual IDs to items within a pop-up menu. If

the selected item in the pop-up menu has an ID attached, Dreamweaver passes that ID to

canAcceptCommand()

instead of the value. For combo boxes, if the current contents of the text box do not match an entry in the pop-up
menu, Dreamweaver passes the contents of the text box. Dreamweaver compares against the pop-up menu without
case-sensitivity to determine whether the contents of the text box match an entry in the list.

If you specify the

arguments

attribute for this toolbar item in the toolbars.xml file, those arguments are passed next.

If you did not specify the

arguments

attribute, Dreamweaver passes the ID of the item.

Returns
Dreamweaver expects a Boolean value;

true

if the item is enabled;

false

otherwise.

Advertising
This manual is related to the following products: