
CHAPTER 4: User-Interface Tools ScriptUI programming model 64
Container elements
All Windows are containers—that is, they contain other elements within their bounds. Within a Window, you
can create other types of container elements:
Panels and Groups. These can contain control elements,
and can also contain other
Panel and Group containers. However, a Window cannot be added to any
container.
X A Group is the simplest container used to visually organize related controls. You would typically define
a group and populate it with related elements, for instance an
edittext box and its descriptive
statictext label.
X A Panel is a frame object, also typically used to visually organize related controls. It has a text property
to specify a title, and can have a border to visually separate the collection of elements from other
elements of a dialog.
X A TabbedPanel is a frame that contains only Tab elements. Each Tab is a frame with a localizable title
in the selection tab, which contains a set of controls. When a tab is active, the
Tab object is the value of
the
TabbedPanel.selection property.
You might create a
Panel and populate it with several Groups, each with their own elements. You can
create nested containers, with different layout properties for different containers, in order to define a
relatively complex layout without any explicit placement.
You can add elements to any container using the
add method (see “Adding elements to containers” on
page 65). An element added to a container is considered a child of that container. Certain operations on a
container apply to its children; for example, when you hide a container, its children are also hidden.
Window layout
When a script creates a Window and adds various user-interface elements to it, the locations and sizes of
elements and spacing between elements is known as the layout of the window. Each user-interface
element has properties which define its location and dimensions:
location, size, and bounds. These
properties are initially undefined, and a script that employs Automatic layout
should leave them
undefined for the main window as well as its contained elements, allowing the automatic layout
mechanism to set their values.
Your script can access these values, and (if not using auto-layout) set them as follows:
X The location of a window is defined by a Point object containing a pair of coordinates (x and y) for
the top left corner (the origin), specified in the screen coordinate system. The
location of an element
within a window or other container is defined as the origin point specified in the container’s
coordinate system. That is, the
x and y values are relative to the origin of the container.
The following examples show equivalent ways of placing the content region of an existing window at
screen coordinates [10, 50]:
win.location = [10, 50];
win.location = {x:10, y:50};
win.location = "x:10, y:50";
X
The size of an element’s region is defined by a Dimension object containing a width and height in
pixels.
Comentários a estes Manuais