Detailed instructions for use are in the User's Guide.
[. . . ] Extending Dreamweaver
Trademarks Add Life to the Web, Afterburner, Aftershock, Andromedia, Allaire, Animation PowerPack, Aria, Attain, Authorware, Authorware Star, Backstage, Bright Tiger, Clustercats, Cold Fusion, Contribute, Design in Motion, Director, Dream Templates, Dreamweaver, Drumbeat 2000, EDJE, EJIPT, Extreme 3D, Fireworks, Flash, Fontographer, FreeHand, Generator, HomeSite, JFusion, JRun, Kawa, Know Your Site, Knowledge Objects, Knowledge Stream, Knowledge Track, LikeMinds, Lingo, Live Effects, MacRecorder Logo and Design, Macromedia, Macromedia Action!, Macromedia Flash, Macromedia M Logo & Design, Macromedia Spectra, Macromedia xRes Logo and Design, MacroModel, Made with Macromedia, Made with Macromedia Logo and Design, MAGIC Logo and Design, Mediamaker, Movie Critic, Open Sesame!, Roundtrip HTML, Shockwave, Sitespring, SoundEdit, Titlemaker, UltraDev, Web Design 101, what the web can be, and Xtra are either registered or trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words or phrases mentioned within this publication may be trademarks, servicemarks, or tradenames of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally. [. . . ] The handlers are guaranteed to run when the user clicks on a toolbar item. Example update="onViewChange"
command="script" This attribute is required for all items except menu buttons. Specifies the JavaScript function to execute when the user performs one of the following actions:
· · · ·
Clicks a button Selects an item from a pop-up menu or combo box Tabs out of, presses Return in, or clicks away from a text box or combo box Selects a color from a color picker
The command attribute is equivalent to the receiveArguments() function in a toolbar command file.
Example command="dw. toggleLiveDebug()"
arguments="argument_list" Optional. This attribute specifies the comma-separated list of arguments to pass to the receiveArguments() function in a toolbar command file. If you do not specify the arguments attribute, Dreamweaver passes the ID of the toolbar item. In addition, pop-up menus, combo boxes, text boxes, and color pickers pass their current value as the first argument, before any arguments that the arguments attribute specifies, and before the item ID if no arguments are specified.
186
Chapter 9: Toolbars
Example
On a toolbar that has Undo and Redo buttons, each button calls the menu command file, Edit_Clipboard. htm, and passes an argument that specifies the action, as shown in the following example:
<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
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. The command file API for toolbar items is an extension of the menu command file API, so you can reuse menu command 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.
The toolbar command API
187
Returns
Dreamweaver expects a Boolean value; true if the item is enabled; false otherwise.
Example function canAcceptCommand() { return (dw. getDocumentDOM() != null); }
getCurrentValue()
Availability
Dreamweaver MX.
Description
Returns the current value to display in the item. Dreamweaver calls the getCurrentValue() function for pop-up menus, combo boxes, text boxes, and color pickers. For pop-up menus, the current value should be one of the items in the menu. If the value is not in the pop-up menu, Dreamweaver selects the first item. For combo boxes and text boxes, this value can be any string that the function returns. For color pickers, the value should be a valid color, but Dreamweaver does not enforce this. This function is equivalent to the value attribute.
Arguments
None.
Returns
Dreamweaver expects a string that contains the current value to display. [. . . ] Contains functions that add a form around a given text string if a form does not already exist in the current document or layer. Includes functions that determine if an object is a layer and determine if the cursor is inside a form. Contains functions that get a function for an event handler, add a function to an event handler, and delete a function for an event handler. Contains a handful of useful functions that replace encoding, unescape quotation marks ("), check whether a node is inside a selection range, and checks for duplicate object names.
displayHelp. js docInfo. js
DOM. js
enableControl. js
errmsg. js file. js
form. js
handler. js
helper. js
380
Appendix A: The Shared Folder
insertion. js
Contains the insertIntoDocument() function, which inserts a text string into a document at the insertion point. [. . . ]