Getcurrentvalue(): get the title, The toolbar definition file – Adobe Extending Dreamweaver CS4 User Manual
Page 176

170
EXTENDING DREAMWEAVER CS4
Toolbars
function receiveArguments(newTitle)
{
var dom = dw.getDocumentDOM();
if (dom)
dom.setTitle(newTitle);
}
Dreamweaver passes
newTitle
, which is the value that the user enters, to the
receiveArguments()
function. The
receiveArguments()
function first checks to see whether a current DOM exists. If it does, the
receiveArguments()
function sets the new document title by passing
newTitle
to the
dom.setTitle()
function.
getCurrentValue(): get the title
Whenever an update cycle occurs, as determined by the default update frequency of the
onEdit
event handler,
Dreamweaver calls the
getCurrentValue()
function to determine what value to display for the control. The default
update frequency of the
onEdit
handler determines the update frequency because the Title text edit control has no
update attribute.
For the Title text box, the following
getCurrentValue()
function calls the JavaScript application programming
interface (API) function
dom.getTitle()
to obtain and return the current title.
The function is as follows:
function getCurrentValue()
{
var title = "";
var dom = dw.getDocumentDOM();
if (dom)
title = dom.getTitle();
return title;
}
Until the user enters a title for the document, the
getTitle()
function returns Untitled Document, which appears in
the text box. After the user enters a title, the
getTitle()
function returns that value, and Dreamweaver displays it as
the new document title.
To see the complete HTML file that contains the JavaScript functions for the Title text box, see the EditTitle.htm file
in the Toolbars/MM folder.
The MM folder is reserved for Adobe files. Create another folder inside the Toolbars folder, and place your JavaScript
code in that folder.
The toolbar definition file
A toolbar is simply a list of radio buttons, check buttons, edit boxes, and other toolbar items, optionally divided by
separator
tags. Each toolbar item can be a reference to an item using the
itemref
tag, a separator using the
separator
tag, or a complete toolbar item definition for a check box or an edit box; for example, as described in
Each toolbar definition file starts with the following declarations:
If the encoding is omitted, Dreamweaver uses the default encoding of the operating system.