Specifications

Chapter 662
The Command API
The custom functions in the Command API are not required.
canAcceptCommand()
Description
Determines whether the command is appropriate for the current selection.
Note: Do not define canAcceptCommand() unless it returns false in at least one case. If the function is not
defined, the command is assumed to be appropriate; making this assumption saves time and improves performance.
Arguments
None.
Returns
Dreamweaver expects true if the command is allowed; false otherwise, dimming the command
in the menu.
Example
The following instance of canAcceptCommand() makes the command available only when the
selection is a table:
function canAcceptCommand(){
var retval=false;
var selObj=dw.getDocumentDOM.getSelectedNode();
return (selObj.nodeType == Node.ELEMENT_NODE && ¬
selObj.tagName=="TABLE");{
retval=true;
}
return retval;
}
commandButtons()
Description
Defines the buttons that should appear on the right side of the Options dialog box and their
behavior when they are clicked. If this function is not defined, no buttons appear, and the
BODY of
the Command file expands to fill the entire dialog box.
Arguments
None.
Returns
Dreamweaver expects an array that contains an even number of elements. The first element is a
string that contains the label for the topmost button. The second element is a string of JavaScript
code that defines the behavior of the topmost button when it is clicked. Remaining elements
define additional buttons in the same way.
Example
The following instance of commandButtons() defines three buttons: OK, Cancel, and Help.
function commandButtons(){
return new Array("OK" , "doCommand()" , "Cancel" , ¬
"window.close()" , "Help" , "showHelp()");
}