
CHAPTER 4: User-Interface Tools Types of controls 67
If you use a creation property to assign a name to a newly created element, you can access that child by its
name, either in the
children array of its parent, or directly as a property of its parent. For example, the
Button in a previous example was named ok, so it can be referenced as follows:
dlg.btnPnl.children['ok'].text = "Build";
dlg.btnPnl.ok.text = "Build";
You can also access named elements through the parent window’s findElement() method:
var myOkButton = dlg.findElement("ok");
For list controls (type list and dropdown), you can access the child list-item objects through the items
array.
Removing elements
To remove elements from a Window, Panel, or Group, use the container’s remove method. This method
accepts an object representing the element to be removed, or the name of the element, or the index of the
element in the container’s
children collection (see “Accessing child elements” on page 66).
The specified element is removed from view if it was currently visible, and it is no longer accessible from
the container or window. The results of any further references by a script to the object representing the
element are undefined.
To remove list items from a list, use the parent list control’s
remove method in the same way. It removes the
item from the parent’s
items list, hides it from view, and deletes the item object.
Types of controls
The following sections introduce the types of controls you can add to a Window or other container element
(
panel or group). For details of the properties and functions, and of how to create each type of element,
see “
Control object constructors” on page 123.
Containers
These are types of Control objects which are contained in windows, and which contain and group other
controls.
Panel
Typically used to visually organize related controls.
X Set the text property to define a title that appears at the top of the panel.
X An optional borderStyle creation property controls the appearance of the border
drawn around the panel.
You can use panels as separators: those with width of 0 appear as vertical lines and
those with height of 0 appear as horizontal lines.
var dlg = new Window(’dialog’, ’Alert Box Builder’);
dlg.msgPnl = dlg.add(’panel’, [25,15,355,130], ’Messages’);
Comentários a estes Manuais