beautypg.com

The menu commands api functions – Adobe Extending Dreamweaver CS4 User Manual

Page 167

background image

161

EXTENDING DREAMWEAVER CS4

Menus and menu commands

}
else
{

// Otherwise, F12 or Ctrl+F12 was pressed, ask if the user wants
// to specify a primary or secondary browser now.
if (whichBrowser == 'primary')
{

result = window.confirm(MSG_NoPrimaryBrowserDefined);

}
else if (whichBrowser == 'secondary')
{

result = window.confirm(MSG_NoSecondaryBrowserDefined);

}

// If the user clicked OK, show the prefs dialog with the browser panel.
if (result)

dw.showPreferencesDialog('browsers');

}

}

}

The function first sets the variable

whichBrowser

to the value that Dreamweaver passes,

arguments[0]

. Along with

setting other default values, the function also sets

result

to a default value of

false

.

After variables are initialized, the

receiveArguments()

function calls the user-defined function

havePreviewTarget()

and tests the result. If the result of the test is true, the function checks to see if the user selected

the primary or secondary browser. If so, the function sets the variable

theBrowser

to the path of the executable file

that starts the browser (

dw.getPrimaryBrowser()

or

dw.getSecondaryBrowser()

). The function then performs a

loop that examines the list of browsers returned by

dw.getBrowsersList()

. If the path to a browser in the list

matches the path to the primary or secondary browser, the function sets the variable

theBrowser

to the matching

value in

browserList

. This value contains the name of the browser and the path to the executable file that starts the

browser. If

havePreviewTarget()

returns the value

false

, the function sets the variable

theBrowser

to the value of

the variable

whichBrowser

.

Next, the

receiveArguments()

function tests the variable

theBrowser

to make sure that it does not begin with a

path, that it is not

"undefined"

, and that it has a length greater than 0. If all these conditions are true, and if the Site

panel has focus, the

receiveArguments()

function calls the

site.browseDocument()

function to invoke the

selected browser with the files selected in the Site panel. If the Site panel does not have focus, the

receiveArguments()

function calls the function

dw.browseDocument()

and passes it the path of the current document and the value of the

variable

theBrowser

, which specifies the name of the browser with which to open the document.

If the user pressed the shortcut keys (F12 or Ctrl+F12) and no primary or secondary browser has been specified, a
dialog box appears to inform the user. If the user clicks OK, the function calls the function

dw.showPreferencesDialog()

with the

browsers

argument to let the user specify a browser at that point.

The menu commands API functions

The custom functions in the menu commands API are not required.

This manual is related to the following products: