
CHAPTER 4: User-Interface Tools ScriptUI programming model 63
ScriptUI programming model
ScriptUI defines Window objects that represent platform-specific windows, and various control elements
such as
Button and StaticText, that represent user-interface controls. These objects share a common set
of properties and methods that allow you to query the type, move the element around, set the title,
caption or content, and so on. Many element types also have properties unique to that class of elements.
Creating a window
ScriptUI defines the following types of windows:
X Modal dialog box: Holds focus when shown, does not allow activity in other application windows until
dismissed.
X Floating palette: Also called modeless dialog, allows activity in other application windows. (Adobe
Photoshop
®
does not support script creation of palette windows.)
X Main window: Suitable for use as an application’s main window. (Main windows are not normally
created by script developers for Adobe applications. Photoshop does not support script creation of
main windows.)
To create a new window, use the
Window constructor function. The constructor takes the desired type of
the window. The type is
"dialog" for a modal dialog, or "palette" for a modeless dialog or floating
palette. You can supply optional arguments to specify an initial window title and bounds; or you can set
the location and size separately.
The following example creates an empty dialog with the variable name
dlg, which is used in subsequent
examples:
// Create an empty dialog window near the upper left of the screen
var dlg = new Window(’dialog’, ’Alert Box Builder’);
dlg.frameLocation = [100,100];
Initially, new windows are hidden. The show method makes them visible and responsive to user
interaction; for example:
dlg.show();
SnpCreateDynamicScriptUI.jsx
Shows how to use automatic layout, switching component
layout between “row” and “stack” orientation.
AlertBoxBuilder1.jsx
Shows a way to use resource specifications. Uses the add()
method to build a dialog that collects values from the user,
and creates a resource string from those values. Saves the
string to a file, then uses it to build a new dialog. See “
Using
resource strings” on page 79.
AlertBoxBuilder2.jsx
Shows another way to use a resource specification, building
the same user-input dialog itself from a resource string. See
“
Using resource strings” on page 79.
SnpCustomLayoutManager.jsx
Shows how to create a customized layout manager. See
“
Custom layout-manager example” on page 95.
Comentários a estes Manuais