Bridge JavaScript Reference for Windows® and Macintosh®.
NOTICE: All information contained herein is the property of Adobe Systems Incorporated. No part of this publication (whether in hardcopy or
electronic form) may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior written consent of Adobe Systems Incorporated. The software described in this document is furnished under
license and may only be used or copied in accordance with the terms of such license.
This publication and the information herein is furnished AS IS, is subject to change without notice, and should not be construed as a
commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or
inaccuracies, makes no warranty of any kind (express, implied, or statutory) with respect to this publication, and expressly disclaims any and
all warranties of merchantability, fitness for particular purposes, and noninfringement of third party rights.
Any references to company names in sample templates are for demonstration purposes only and are not intended to refer to any actual
organization.
Adobe, the Adobe logo, Acrobat, GoLive, Illustrator, Photoshop, InDesign, and Version Cue are either registered trademarks or trademarks of
Adobe Systems Incorporated in the United States and/or other countries.
Apple, Mac, Macintosh, and Mac OS are trademarks of Apple Computer, Inc., registered in the United States and other countries. Microsoft,
and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and other countries. JavaScript
and all Java-related marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. UNIX is
a registered trademark of The Open Group.
All other trademarks are the property of their respective owners.
If this guide is distributed with software that includes an end user agreement, this guide, as well as the software described in it, is furnished
under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part
of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording,
or otherwise, without the prior written permission of Adobe Systems Incorporated. Please note that the content in this guide is protected
under copyright law even if it is not distributed with software that includes an end user license agreement.
The content of this guide is furnished for informational use only, is subject to change without notice, and should not be construed as a
commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or
inaccuracies that may appear in the informational content contained in this guide.
Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA.
About This Book............................................................................................................................................................................19
Who should read this book ................................................................................................................................................19
What is in this book ...............................................................................................................................................................19
Where to go for more information ..................................................................................................................................21
Communicating with Other Applications.....................................................................................................................23
The Bridge Document Object Model ...................................................................................................................................23
The application and documents.......................................................................................................................................24
Thumbnails in documents..................................................................................................................................................25
Thumbnails as node references .................................................................................................................................25
Using and accessing thumbnails ...............................................................................................................................25
User interface objects...........................................................................................................................................................26
The Bridge DOM and the Bridge Browser Window..........................................................................................................28
2Event Handling and Script-Defined Browse Schemes ............................................................ 31
Event Handling in Bridge...........................................................................................................................................................31
Defining and registering a browse scheme .................................................................................................................36
3Creating a User Interface ..........................................................................................................38
User Interface Options for Scripts...........................................................................................................................................38
ScriptUI User Interfaces ..............................................................................................................................................................40
Displaying ScriptUI elements in a navigation bar ......................................................................................................40
Displaying HTML in Bridge........................................................................................................................................................42
Defining callbacks for HTML scripts ................................................................................................................................42
Executing script functions defined on HTML UI pages ............................................................................................43
Displaying HTML in Bridge Dialogs........................................................................................................................................44
3
Adobe Creative Suite 2
Bridge JavaScript Reference 4
Communicating with Bridge from dialog JavaScript................................................................................................44
Using callbacks in an HTML dialog ..................................................................................................................................45
Calling functions defined in an HTML dialog ........................................................................................................47
Displaying HTML in a Navigation Bar ....................................................................................................................................47
Using callbacks from an HTML navigation bar............................................................................................................47
Calling functions defined in an HTML navigation bar..............................................................................................48
Displaying HTML in the Content Pane..................................................................................................................................50
Callback example: Requesting specific metadata value for a file.........................................................................50
Passing Complex Values in Remote Calls ............................................................................................................................51
Passing an object from Bridge to HTML/JavaScript ..................................................................................................52
Scheduling tasks from callbacks .............................................................................................................................................53
Scheduling a remote function execution......................................................................................................................54
4Using File and Folder Objects ................................................................................................... 56
Absolute and relative path names...................................................................................................................................56
Character interpretation in paths.....................................................................................................................................57
The home directory...............................................................................................................................................................57
Volume and drive names ....................................................................................................................................................58
Mac OS volumes...............................................................................................................................................................58
Windows drives ................................................................................................................................................................58
ScriptUI Programming Model ..................................................................................................................................................61
Creating a window ...............................................................................................................................................................61
Adding elements to containers ........................................................................................................................................63
Accessing child elements ............................................................................................................................................64
Removing elements ..............................................................................................................................................................65
Types of controls ...................................................................................................................................................................65
Group .................................................................................................................................................................................65
User interface controls...................................................................................................................................................65
Prompts and alerts ...............................................................................................................................................................69
Creating and using modal dialogs ............................................................................................................................69
Dismissing a modal dialog ...........................................................................................................................................70
Default and cancel elements.......................................................................................................................................70
Defining Behavior for Controls with Event Callbacks .....................................................................................................73
Simulating user events.........................................................................................................................................................73
Aligning children .............................................................................................................................................................76
Spacing between children ...........................................................................................................................................79
Determining a preferred size.......................................................................................................................................79
Creating more complex arrangements ...................................................................................................................79
The AutoLayoutManager algorithm ...............................................................................................................................84
Example scripts .............................................................................................................................................................................86
Localization in ScriptUI Objects ..............................................................................................................................................91
Variable values in localized strings ..................................................................................................................................91
language ...........................................................................................................................................................................94
version ...............................................................................................................................................................................95
active ..................................................................................................................................................................................98
title ......................................................................................................................................................................................98
center .................................................................................................................................................................................98
open ..................................................................................................................................................................................99
place ...................................................................................................................................................................................99
id ....................................................................................................................................................................................... 100
where .............................................................................................................................................................................. 107
open ................................................................................................................................................................................ 108
open ................................................................................................................................................................................ 109
ok ...................................................................................................................................................................................... 110
Multiple references to the same node .................................................................................................................. 124
children .......................................................................................................................................................................... 125
open ................................................................................................................................................................................ 127
File class properties............................................................................................................................................................ 130
File class functions.............................................................................................................................................................. 130
alias .................................................................................................................................................................................. 132
open ................................................................................................................................................................................ 134
Folder class properties ...................................................................................................................................................... 138
current ............................................................................................................................................................................ 138
Folder class functions ........................................................................................................................................................ 139
alias .................................................................................................................................................................................. 140
Window class properties .................................................................................................................................................. 147
version ............................................................................................................................................................................ 147
Window class functions .................................................................................................................................................... 147
children .......................................................................................................................................................................... 150
center .............................................................................................................................................................................. 151
show ................................................................................................................................................................................ 152
Control Objects ......................................................................................................................................................................... 154
Control object constructors ............................................................................................................................................ 154
Control types and creation parameters................................................................................................................ 154
Control object properties................................................................................................................................................. 160
active ............................................................................................................................................................................... 160
text ................................................................................................................................................................................... 163
value ................................................................................................................................................................................ 163
value ................................................................................................................................................................................ 163
Control object functions................................................................................................................................................... 164
show ................................................................................................................................................................................ 164
Control event-handling callbacks................................................................................................................................. 165
Point ................................................................................................................................................................................ 167
MenuElement class functions......................................................................................................................................... 169
Creating new menu elements.................................................................................................................................. 170
id ....................................................................................................................................................................................... 172
text ................................................................................................................................................................................... 172
Bridge menu and command identifiers...................................................................................................................... 172
Bridge menu identifiers.............................................................................................................................................. 172
Bridge submenu and command identifiers ....................................................................................................... 173
9Interapplication Communication with Scripts ...................................................................... 180
Cross-DOM API Reference...................................................................................................................................................... 181
open ................................................................................................................................................................................ 181
Handling responses from the message target......................................................................................................... 187
Passing values between applications.......................................................................................................................... 190
BridgeTalk class properties ....................................................................................................................................... 193
BridgeTalk class functions ......................................................................................................................................... 194
10 ExtendScript Tools and Features............................................................................................203
The ExtendScript Toolkit......................................................................................................................................................... 203
Configuring the Toolkit window ................................................................................................................................... 204
Selecting a debugging target ........................................................................................................................................ 205
Tracking data ........................................................................................................................................................................ 206
The JavaScript console ..................................................................................................................................................... 207
The call stack ........................................................................................................................................................................ 208
The Script Editor .................................................................................................................................................................. 209
Mouse navigation and selection ............................................................................................................................. 209
Keyboard navigation and selection ....................................................................................................................... 209
Debugging in the Toolkit ................................................................................................................................................. 210
Evaluation in help tips................................................................................................................................................. 210
Visual indication of execution states ..................................................................................................................... 211
Dollar ($) Object ........................................................................................................................................................................ 215
Dollar ($) object properties ............................................................................................................................................. 215
global .............................................................................................................................................................................. 215
os ...................................................................................................................................................................................... 216
version ............................................................................................................................................................................ 216
Dollar ($) object functions ............................................................................................................................................... 216
bp ..................................................................................................................................................................................... 216
list ..................................................................................................................................................................................... 216
max .................................................................................................................................................................................. 221
min ................................................................................................................................................................................... 221
Global localize function .................................................................................................................................................... 225
User Notification Helper Functions..................................................................................................................................... 226
Global alert function .......................................................................................................................................................... 226
Global confirm function.................................................................................................................................................... 227
Global prompt function.................................................................................................................................................... 227
value ................................................................................................................................................................................ 230
Converting pixel and percentage values ................................................................................................................... 230
Computing with unit values ........................................................................................................................................... 231
Modular Programming Support .......................................................................................................................................... 233
#engine name .............................................................................................................................................................. 233
#script name ................................................................................................................................................................. 234
#strict on ........................................................................................................................................................................ 234
#target name ................................................................................................................................................................ 234
Importing and exporting between scripts................................................................................................................. 234
Application and Namespace Specifiers............................................................................................................................. 237
Script Locations and Checking Application Installation ............................................................................................. 238
Index .........................................................................................................................................240
Adobe Creative Suite 2
Bridge JavaScript Reference 18
Wel com e
Welcome to the Bridge JavaScript Reference. This book describes how to use JavaScript to manipulate and
extend Adobe® Bridge for Adobe Creative Suite 2.
About This Book
The Bridge JavaScript Reference describes how to use the scripting API to extend and manipulate Adobe
Bridge, but it is not a user’s guide for the Bridge application and its user interface.
This book provides complete reference information for the JavaScript objects, properties, and functions
defined by Adobe Bridge, and for various utilities and tools that are part of ExtendScript, the Adobe
extended implementation of JavaScript.
This book also describes how to use the interapplication communication framework that is defined by
Adobe Bridge and included in each Adobe Creative Suite 2 application. You can use this framework to
write scripts that call on functionality from different applications, or to send scripts and data from one
application to another. A set of Sample Workflow Automation Scripts
Suite 2, which demonstrate how scripts can be used to create a workflow that takes advantage of
functionality in different applications.
is provided with Adobe Creative
Who should read this book
This book is for developers who want to extend the capabilities of Adobe Bridge using JavaScript, call
Bridge functionality from scripts, and use scripts to communicate between Adobe Creative Suite 2
applications. It assumes a general familiarity with the following:
● JavaScript
● C and C++ programming
● Adobe Bridge
● Any other Adobe Creative Suite 2 applications you are using, such as Illustrator® CS2, Photoshop® CS2,
or InDesign® CS2. The scripting API details for each application are included with the scripting
documentation for that product.
What is in this book
This book provides conceptual information about the scripting Adobe Bridge and detailed reference
information about the JavaScript objects that Adobe Bridge provides. It also provides both usage and
reference information for the tools, utilities, and objects that are part of ExtendScript, the Adobe extended
implementation of JavaScript.
This book contains the following chapters:
● Chapter 1, “Scripting Bridge,” introduces some important concepts in Adobe Bridge scripting and
describes the Bridge JavaScript document object model (DOM).
● Chapter 2, “Event Handling and Script-Defined Browse Schemes,” describes how Adobe Bridge
generates user-interaction events, and how you can respond to these events by defining handlers in
19
Adobe Creative Suite 2
Bridge JavaScript Reference Welcome 20
your scripts. In addition, it describes how to define browse schemes that allow you to extend or modify
what is shown in the Bridge Favorites pane.
● Chapter 3, “Creating a User Interface,” describes the various options available to scripts for interaction
with Bridge users, such as dialog boxes and navigation bars.
● Chapter 4, “Using File and Folder Objects,” describes how to use the ExtendScript objects that provide
platform-independent access to the underlying file system.
● Chapter 5, “Using ScriptUI,” describes how to use the ExtendScript user interface module, a set of
objects which provide windows and user-interface controls for the scripting environment.
● Chapter 6, “Bridge DOM Object Reference,” provides a complete API reference for the objects,
properties, and functions defined in the Bridge document object model.
● Chapter 7, “File and Folder Object Reference,” provides a complete API reference for the ExtendScript
file-system access objects, properties, and functions.
● Chapter 8, “ScriptUI Object Reference,” provides a complete API reference for the ExtendScript
user-interface objects, properties, and functions.
● Chapter 9, “Interapplication Communication with Scripts,” describes how to use the interapplication
communication framework, and provides a complete API reference for the Cross-DOM and for the
messaging framework.
● Chapter 10, “ExtendScript Tools and Features,” describes the ExtendScript Toolkit debugging
environment, and provides a complete API reference for the ExtendScript utilities and features that are
available to all Adobe Creative Suite 2 applications.
Document conventions
Typographical conventions
Monospaced font
ItalicsVariables or placeholders in code. For example, in
Blue underlined text
Sans-serif bold fontThe names of Bridge UI elements (menus, menu items, and buttons).
Note: Notes highlight important points that deserve extra attention.
A hyperlink you can click to go to a related section in this book or to a URL in
Literal values and code, such as JavaScript code, HTML code, filenames, and
pathnames.
name="myName", the text
myName represents a value you are expected to supply, such as name="Fred".
Also indicates the first occurrence of a new term.
your web browser.
> symbol is used as shorthand notation for navigating to menu items. For
The
example,
Edit > Cut refers to the Cut item in the Edit menu.
JavaScript conventions
This reference does not list properties and methods provided by the JavaScript language itself. For
example, it is common for JavaScript objects to provide a
the SDK supplies implement this method. However, this book does not describe such methods unless they
differ from the standard JavaScript implementation.
toString method, and many of the objects
Adobe Creative Suite 2
Bridge JavaScript Reference Welcome 21
Similarly, because most objects provided by the SDK have a name property, the reference does not list
name properties explicitly.
When a JavaScript function returns a value, it is listed.When there is no return value listed, the function
does not return a value.
Where to go for more information
This book does not describe the JavaScript language. For documentation of the JavaScript language or
descriptions of how to use it, see any of numerous works on this subject, including the following:
JavaScript: The Definitive Guide, 4th Edition; Flanagan, D.; O’Reilly 2001; ISBN 0-596-00048-0
JavaScript Programmer’s Reference; Wootton, C.; Wrox 2001; ISBN 1-861004-59-1
JavaScript Bible. 5th Edition; Goodman, D. and Morrison, M.; John Wiley and Sons1998; ISBN
0-7645-57432
1
Scripting Bridge
This chapter introduces some important concepts in Adobe Bridge scripting and describes the Bridge
JavaScript document object model (DOM).
Scripting Overview
Adobe Bridge provides a configurable, extensible browser platform that allows users to search for and
select files by navigating among files and folders in the local file system, those on remote file systems, and
also web pages accessible over the Internet.
Bridge is integrated with Adobe Creative Suite 2, and various applications bring up the Bridge browser
window in response to specific user actions that require file selection. You can also bring up a Bridge
browser window independently, by invoking it interactively or through a script.
The Bridge browser is highly configurable and extensible, using ExtendScript, the Adobe extended
implementation of JavaScript. ExtendScript files are distinguished by the
offers all standard JavaScript features, plus additional features and utilities, such as:
● Platform-independent file and folder representation
● Tools for building a user interface to a script
.jsx extension. ExtendScript
● An interactive development and debugging environment (the ExtendScript Toolkit)
You can use ExtendScript to manipulate browser windows and their contents programmatically, and to
change and extend their functionality. This manual describes what you can do, and provides a complete
reference for the ExtendScript objects and functions that you can use to program Bridge.
Executing Scripts
Bridge executes scripts in any of these ways:
● On startup, Bridge executes all JSX files that it finds in the startup folders.
Note: If your script is in the main startup folder, it is also executed by all other Adobe Creative Suite 2
applications at startup; see Script Locations and Checking Application Installation
The version portion of the Bridge-specific folder path is an exact version number. That is, scripts in the
bridge/1.5 are executed only by Bridge version 1.5, and so on.
folder
®
, the startup folders are:
®
, the startup folders are:
.
● You can pass a script to the Bridge executable to be executed on startup, by dragging the JSX file icon
onto the Bridge executable file icon or shortcut. This script is executed after all startup scripts.
22
Adobe Creative Suite 2
Bridge JavaScript Reference Scripting Bridge 23
● When the Bridge browser window displays a JSX file, you can double-click that file thumbnail to run the
script in its target application. It runs in Bridge if the script specifies Bridge as its target application by
including the directive:
#target "bridge"
If the script specifies another Adobe Creative Suite 2 application as its target, ExtendScript starts that
application if necessary. If the script does not specify a target application, it opens in the ExtendScript
Toolkit. For details, see Preprocessor directives
● You can load and run a script in the ExtendScript Toolkit, specifying Bridge as the target application.
For details, see The ExtendScript Toolkit
● You can add a menu command that runs a script to a menu or submenu in the Bridge browser, using
the MenuElement Object
.
and The ExtendScript Toolkit.
.
Communicating with Other Applications
Adobe Bridge provides an interapplication communication framework, a way for scripts to communicate
with other Adobe applications, from Bridge or among themselves.
● A script can call certain basic functions exported by all Adobe Creative Suite 2 applications. For
example, a Bridge script could ask the user to select an image file, then open that file in Photoshop
Illustrator
® by calling the photoshop.open or illustrator.open function. These basic exported
functions are called the Cross DOM.
® or
● Individual applications export additional functions to make more complex functionality available to
scripts. For example, a Bridge script can request a photo-merge operation in Photoshop by calling
photoshop.photomerge with a set of selected image files. The set of functions available for each
application varies widely.
● A messaging protocol provides a general and extensible framework for passing any kind of data
between messaging enabled applications. All Creative Suite 2 applications are messaging enabled. You
can send messages that contain JavaScript scripts. The target application can evaluate a script that it
receives, and send results back in a response message.
For additional information, see Chapter 9, “
Interapplication Communication with Scripts."
The Bridge Document Object Model
A document object model (DOM) is an application programming interface (API), which allows you to
programmatically access various components of a document (as defined for that application) through a
scripting language such as JavaScript.
Each application in the Creative Suite 2 has its own DOM, which consists of a hierarchical representation of
the application, and of the documents used in the application. The DOM allows you to programmatically
access and manipulate the document and its components. Since the use of a document varies for each
application, the DOM terminology varies for each application. For example, each application's DOM
includes a
class has different properties and methods for each application.
Document class, but the object referred to is different for each application, and the Document
Applications typically define a
images, or PDF documents. However, Bridge uses a different approach. In the Bridge DOM, the
class refers to a Bridge browser window, and the properties and methods of
Document class to deal with files of a particular type, such as HTML pages,
Document
Document refer to various
components of the Bridge user interface (UI). The browser window displays icons that reference the files
Adobe Creative Suite 2
Bridge JavaScript Reference Scripting Bridge 24
that other applications consider documents—HTML pages, images, PDFs, and so on. In the Bridge DOM,
these icons are represented by the
Thumbnail class.
Having a good understanding of the Bridge DOM, and how each aspect of the API relates to the Bridge
browser, will greatly enhance your ability to write scripts. In the Bridge DOM shown below, each node in
the hierarchy represents a class in the Bridge DOM API.
AppApp
Document
Event
Dialog
MenuElement
Preferences
PreferencesDialog
Favorites
Thumbnail
NavBar
Thumbnail
File, Folder
MetaData
BrowseSchemeEvent
ScriptUI Element
The application and documents
The Bridge App Object is the root of the hierarchy, and represents the Bridge application. A single global
instance of the
global values. Even though the user can create multiple Bridge browser windows by selecting the File >
New Window command, making it appear that separate Bridge applications are running in parallel, only a
single instance of the application is running, which is reflected by a single instance of the
The Document Object
document object is created. When multiple Bridge browser windows are open, the user can select
a new
which window to use by clicking the window to make it active. In a script, you can access the active, or
most recently used, browser window through the
windows is available through the
App class, named app, is created when the application is started, and provides access to
represents a Bridge browser window. Each time a user selects File > New Window,
app.documents array.
app object.
app.document property. The set of all open browser
Adobe Creative Suite 2
Bridge JavaScript Reference Scripting Bridge 25
Thumbnails in documents
The Thumbnail Object type represents a node in the browser navigation hierarchy. It typically represents a
a file or folder, but can also be associated with a web page. A document contains various collections of
Thumbnail objects.
Thumbnail objects can contain other Thumbnail objects, as for example, when a folder contains files. In
this case, the
represent files and folders contained in the folder.
The Folders pane shows the full navigation hierarchy of folders and subfolders for the local file system. A
script cannot add nodes to the Folders pane (except by creating new folders on disk), but your script can
access the selected thumbnail through the
navigation hierarchy by accessing the
The Favorites pane shows a selection of high-level nodes, some predefined and some chosen by the user.
These can represent web pages and remote folders, as well as local folders. The Favorites Object
represents the navigation nodes in the Favorites pane. A document contains a single
which is an array of
children property of the Thumbnail contains a hierarchy of Thumbnail objects that
app.document.thumbnail property. It can walk the
parent and children properties of each Thumbnail object.
Favorites object,
Thumbnail objects. Access the Favorites object through app.favorites.
A script can add thumbnails to the lower part of the Favorites pane by using the
Favorites object’s
insert method, and one level of sub-nodes using the addChild method. A subnode can be any
thumbnail; it does not have to be part of the root node’s
children hierarchy.
Thumbnails as node references
The Thumbnail Object represents a navigation node. Thumbnails can represent entities such as files and
folders, accessed through a local or remote file system, or web pages accessed over the internet and
displayed in an embedded web browser. Each
types of node identifier, which determines what happens when the user selects the icon:
● File or folder objects; see Chapter 4, “Using File and Folder Objects," and Chapter 7, “File and Folder
Object Reference." Clicking a folder thumbnail in the Folders or Favorites pane displays the contents of
the folder in the Content pane.
● URLs. Clicking the thumbnail in the Folders or Favorites pane displays the web page associated with
the URL in the Content pane. This can be a local or remote HTML page. See Displaying HTML in the
Content Pane.
● Version Cue® nodes. Clicking a thumbnail in the Folders pane displays the contents of the Version Cue
workspace in the Content pane.
● Script-defined navigation nodes, which are associated with script-defined browse schemes. The display
in the Content pane is determined by the browse scheme’s associated handler. See Script-Defined
Browse Schemes.
Thumbnail object is associated with one of the following
Using and accessing thumbnails
Thumbnails are used in a number of ways within a browser window, and the objects are referenced
according to their use. For example:
● Access thumbnails that appear in the Favorites pane through app.favorites
● Access a thumbnail that is selected in the Folders pane through app.document.thumbnail
● Access thumbnails that appear in the Content pane through
app.document.thumbnail.children
Adobe Creative Suite 2
Bridge JavaScript Reference Scripting Bridge 26
● Access thumbnails that have been selected in the Content pane through app.document.selected
● Access thumbnails that are associated with a context menu through app.document.context
A Thumbnail object is associated with a Metadata Object, which allows you to access the external data
associated with the associated file, such a copyright owner, author, or camera settings. The
metadata
object also allows access to an image thumbnail’s label string, which you can define and set through the
Bridge browser.
User interface objects
Your script can display information to or collect information from the user by configuring the supplied
navigation bars, or by creating and displaying dialogs.
ExtendScript provides a set of user-interface objects in the ScriptUI module, which defines windows and
user-interface controls. You can use these objects to define a user interface for your application, in the
form of popup dialogs, persistent dialogs (called palettes), or as part of navigation bars. The usage of the
ScriptUI objects is discussed in Chapter 5, “
Chapter 8, “
ScriptUI Object Reference."
You can also define a user interface using standard HTML. When integrating your user interface with the
Bridge browser, you can use either ScriptUI or HTML controls for any window or pane, but cannot mix the
two. For a complete discussion, see Chapter 3, “
Using ScriptUI," and complete syntax details are provided in
Creating a User Interface."
In addition to displaying a user interface for your script, you can script user interactions by extending the
Bridge menus.
Navigation bars
The Bridge navigation bar immediately below the menubar cannot be scripted, but there are two
configurable navigation bars, above and below the Content pane. They are represented by NavBar
Objects, which you can access through the Document object’s navbars property.
By default, the navigation bars are hidden and empty.
● You can show and hide a navigation bar by setting the object’s visible property.
● You can configure a navigation bar to display either ScriptUI user-interface controls, or straight HTML
controls. It cannot mix the two.
● To display ScriptUI controls, set the type property to "scriptui", then use the NavBar.add
method to add controls.
● To display HTML controls, set the type property to "html", and the file property to the HTML
file that defines the page you want to display.
You can program the controls to display information to or collect information from the user. For additional
details, see Navigation Bars
.
Dialogs
Your script can define dialogs to display information to or get information from the user. There are two
ways to define these:
● ScriptUI Dialogs: Use the ScriptUI Window Object to define a dialog that displays ScriptUI controls.
Adobe Creative Suite 2
Bridge JavaScript Reference Scripting Bridge 27
● Bridge Dialogs: The Dialog Object represents a window that displays an HTML page, rather than
ScriptUI controls.
You can invoke ScriptUI dialogs from a script as modal or nonmodal dialogs.
● A modal dialog retains the input focus, and does not allow the user to interact with any other
application windows until the dialog is dismissed. The function that invokes it does not return until the
dialog is dismissed.
● A nonmodal dialog (known in ScriptUI as a palette), does not keep the input focus. The user can interact
with other application windows while the dialog is up. The function that invokes it returns
immediately, leaving the dialog on screen until the user or script closes it.
Menus
Events
For details of programming dialogs, see Chapter 5, “
Using ScriptUI," a n d Displaying HTML in Bridge
Dialogs.
The MenuElement Object allows you to add new menus and commands. A script cannot remove or alter
the behavior of predefined menu items, but you can add, remove, and modify script-defined menus and
commands.
Most menubar menus and context menus can be extended by creating new
MenuElement objects that
reference existing menus and menu items. The identifiers of all menus and menu items that are accessible
to scripts are listed with the description of the
MenuElement object.
When interacting with Bridge, a user takes actions such as copying a file, or creating a new Bridge browser
window. For most of these actions, Bridge triggers a user-interaction event, represented by an Event Object
of a particular event type, with a particular target object, such as an
App, Document, or Thumbnail object.
Some function calls can also trigger events.
Bridge defines default behavior for user-interaction events. You can extend or override the default
behavior by defining and registering an event-handler function. This function receives the
Event object as
an argument, and returns a value that tells Bridge whether to continue with the default behavior or to
ignore it.
For more information on event handling, see Event Handling in Bridge
Application preferences
The Preferences Object allows a script to access Bridge application preferences. These are the values that
can be viewed interactively in the Preferences dialog, in response to the Edit > Preferences command.
The settings are stored and persist across sessions. Your script can use the
set existing preferences, or to add new preference fields. In general, when you modify persistent
preference values, the new settings are not reflected in the browser window until the Bridge application is
restarted.
When the user brings up a Preferences dialog, Bridge invokes a ScriptUI dialog window, and generates a
create event with the PreferencesDialog Object as its target. You can define and register an event
handler for this event that uses the object’s
controls that show and allow the user to modify script-defined preference values.
.
Preferences object to view or
add method to add a ScriptUI panel containing ScriptUI
Adobe Creative Suite 2
Bridge JavaScript Reference Scripting Bridge 28
The Bridge DOM and the Bridge Browser Window
The following figure identifies parts of the Bridge browser window in a default configuration.
Menu bar
Upper
navigation bar
Favorites and
Folder panes
User section of
Favori tes pane
Preview pane
Metadata and
Keywords panes
Flyout menus
Status line
Content pane
ThumbnailsThumbnails
Viewing mode
The following table describes how the Bridge API maps to the various parts and features of the Bridge
browser window, and how a script can access each part or feature through the Bridge DOM.
Bridge window area Purpose Bridge DOM control
Browser windowDisplays files, folders, and web
pages.
Favorites pane Provides a place for users to
drag and drop favorite items
(in the bottom half of the
pane).
Displays only top-level
containers and one level of
subnodes.
Represented by the
browser window is in
Document object. Current
app.document.
Access the visible thumbnails through the
app.favorites property, and traverse the
hierarchy through the
Thumbnail.children
properties.
Favorites object allows you to add
The
thumbnails to this pane.
User interaction with a thumbnail in this
pane generates an
target object and a location of
event with a Thumbnail
favorites.
You can define your own browse scheme for a
thumbnail in this pane, which allows you to
extend or redefine the thumbnail’s behavior.
See Script-Defined Browse Schemes
.
Adobe Creative Suite 2
Bridge JavaScript Reference Scripting Bridge 29
Folders pane Displays the navigation
hierarchy and controls
navigation.
Displays only containers (such
as folders and subfolders).
Access the currently selected thumbnail in
the Folder pane through the
Document.thumbnail property. Traverse the
hierarchy through the
Thumbnail.children properties.
Thumbnail.parent and
User interaction with a thumbnail in this
pane generates an
target object and a location of
event with a Thumbnail
document.
Preview pane Displays image previews.User interaction with a thumbnail in this
Metadata pane Displays metadata
information.
pane generates an
target object and a location of
Metadata is displayed and written for a
specific thumbnail. Access metadata from
the
Thumbnail.metadata property.
event with a Thumbnail
preview.
Keywords pane Displays keyword information. Not accessible to scripts.
Content pane Displays navigation results
when you select a node in the
Folders or Favorites pane, or
when you click on a navigable
node (such as a folder) in the
Content pane itself.
Controlled by the browse scheme associated
with the thumbnail selected in the Folders or
Favorites pane. The browse scheme uses the
Thumbnail properties displayMode and
displayPath to determine what appears the
Content pane, and how it appears.
Displays both containers (such
as subfolders) and leaf nodes
(such as files and images).
Can display HTML pages for
web-type thumbnails.
Thumbnails The labelled icons that appear
in the Folders/Favorites panes
as navigation nodes, and in
the Content pane to represent
files and folders.
● When the selected thumbnail has
displayMode="filesystem", its children
appear as icons in the Content pane.
When a folder is selected in the Folders
pane, access the current contents of the
Content pane through
app.document.thumbnail.children[].
● When the selected thumbnail has
displayMode="web", the associated HTML
page (local or remote) appears in the
Content pane.
User interaction with a thumbnail in this
pane generates an
target object and a location of
event with a Thumbnail
document. The
selected thumbnails are available through
Document.selections.
The
Thumbnail object represents a node in
the browser navigation hierarchy.
Thumbnails can represent
File or Folder
objects, Version Cue nodes, URLs, or
script-defined nodes associated with
script-defined browse schemes.
Adobe Creative Suite 2
Bridge JavaScript Reference Scripting Bridge 30
Menubar The menubar at the top of the
Bridge browser window.
Context menus The right-click menus
associated with thumbnails,
and flyout menus for some tab
panels.
Browser window upper
navigation bar
The navigation bar
immediately under the
menubar. Not configurable.
Status line The bottom bar on the Bridge
browser window.
Content Pane Viewing
Control
The bar next to the status line,
where the viewing mode of
the Content pane is controlled.
Top and bottom
navigation bar s
Two configurable navigation
bars that can appear above
and below the Content pane.
While this is not an object under direct
Document control, you can add menus and
commands using the
MenuElement object, by
referring to existing menus and commands.
You can add submenus and commands to
these menus using the
MenuElement object,
by referring to existing commands.
Not accessible to scripts.
Controlled by
The view mode is controlled by
app.document.thumbnailViewMode
Represented by predefined
accessed through the
Document.status.
.
NavBar objects,
Document.navbars
property. By default, the navigation bars are
invisible. You can make a bar visible, and add
ScriptUI or HTML UI controls to it.
Loading...
+ 214 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.