CHAPTER 4: User-Interface Tools ScriptUI programming model 65
The following examples show equivalent ways of changing an existing window’s width and height to
200 and 100:
win.size = [200, 100];
win.size = {width:200, height:100};
win.size = "width:200, height:100";
This example shows how to change a window’s height to 100, leaving its location and width
unchanged:
win.size.height = 100;
X
The bounds of an element are defined by a Bounds object containing both the origin point (x, y) and
size (
width, height) To define the size and location of windows and controls in one step, use the
bounds property.
The value of the
bounds property can be a string with appropriate contents, an inline JavaScript
Bounds object, or a four-element array. The following examples show equivalent ways of placing a 380
by 390 pixel window near the upper left corner of the screen:
var dlg = new Window(’dialog’, ’Alert Box Builder’, [100,100,480,490]);
dlg.bounds = [100,100,480,490];
dlg.bounds = {x:100, y:100, width:380, height:390};
dlg.bounds = {left:100, top:100, right:480, bottom:490};
dlg.bounds = "left:100, top:100, right:480, bottom:490";
The window dimensions define the size of the content region of the window, or that portion of the window
that a script can directly control. The actual window size is typically larger, because the host platform’s
window system typically adds title bars and borders. The
bounds property for a Window refers only to its
content region. To determine the bounds of the frame surrounding the content region of a window, use
the
Window.frameBounds property.
Adding elements to containers
To add elements to a window, panel, or group, use the container’s add method. This method accepts the
type of the element to be created and some optional parameters, depending on the element type. It
creates and returns an object of the specified type.
In additions to windows, ScriptUI defines the following user-interface elements and controls:
X Panels (frames) and groups, to collect and organize other control types
X Push buttons with text or icons, radio buttons, checkbox buttons
X Static text or images, edit text
X Progress bars, scrollbars, sliders
X Lists, which include list boxes, drop-down (also called popup) lists, and tree views. Each item in a list is
a control of type
item, and the parent list’s items property contains an array of child items. Tree views
can also have collapsible
node-type items, which contain child items. You can add list items with the
parent’s
add method.
You can specify the initial size and position of any new element relative to the working area of the parent
container, in an optional
bounds parameter. Different types of elements have different additional
parameters. For elements which display text, for example, you can specify the initial text. See the ScriptUI
Classes dictionary in the ExtendScript Toolkit’s Object Model Viewer for details.
Comentários a estes Manuais