Note:
Do not define canAcceptCommand() unless it returns a value of 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.
Dreamweaver expects a true value if the command is allowed; if the value is false, Dreamweaver dims the command in the menu.
The following example of the canAcceptCommand() function 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; }
This function defines the buttons that appear on the Options dialog box and their behaviors when they are clicked. If this function is not defined, no buttons appear and the body section of the command file expands to fill the entire dialog box.
By default, these buttons appear at the top of the dialog box. You can choose to display these buttons at the bottom of the dialog box by specifying two additional values in the commandButtons() function.
Buttons are right-aligned by default. Specifying the value, PutButtonOnLeft, aligns subsequent buttons to the left on the same line.
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. The remaining elements define additional buttons in the same way.
The following instance of commandButtons() defines three buttons: OK, Cancel, and Help that appear at the upper-right corner (default position) of the dialog box:
function commandButtons(){ return new Array("OK" , "doCommand()" , "Cancel" , "window.close()" , "Help" , "showHelp()"); }
The following instance of commandButtons() displays the buttons at the bottom of the dialog box. When the first value in the return array is PutButtonsOnBottom, you can specify the second value as defaultButton along with one of the button names. This button is selected by default and used when the Enter key is pressed. In this example, the OKbutton is defined as the default.
function commandButtons(){ return new Array("PutButtonsOnBottom" , "OkButton defaultButton" , "OK" , "doCommand()" , "Cancel" , "window.close()" , "Help" , "showHelp()"); }
function commandButtons(){ return new Array("PutButtonsOnBottom", "OkButton defaultButton", "OK", "doCommand()", "Cancel", "window.close()", "PutButtonOnLeft", "Help" , "showHelp()");}
This function determines whether the command requires a valid DOM to operate. If this function returns a value of true or if the function is not defined, Dreamweaver assumes that the command requires a valid DOM and synchronizes the Design and Code views of the document before executing. Synchronization causes all edits in the Code view to update in the Design view.
This function processes any arguments that pass from a menu item or from the dw.runCommand() function.
If the arguments attribute is defined for a menuitem tag, the value of that attribute passes to the receiveArguments() function as one or more arguments. Arguments can also pass to a command by the dw.runCommand() function.
This function sets specific dimensions for the Parameters dialog box. If this function is not defined, the window dimensions are computed automatically.
Note:
Do not define this function unless you want an Options dialog box that is larger than 640 x 480 pixels.
The value of the platform argument is either "macintosh" or "windows", depending on the user’s platform.
Dreamweaver expects a string of the form "widthInPixels,heightInPixels".
The returned dimensions are smaller than the size of the entire dialog box because they do not include the area for the OK and Cancel buttons. If the returned dimensions do not accommodate all options, scroll bars appear.
The following example of the windowDimensions() function sets the dimensions of the Parameters dialog box to 648 x 520 pixels:
function windowDimensions(){ return "648,520"; }