
CHAPTER 4: User-Interface Tools Types of controls 69
Image
Displays an iconic image.
X The image property identifies the icon image; see “Displaying images” on
page 72.
X The title property provides an optional label; the titleLayout property places
the label with respect to the image.
StaticText
Typically used to display text strings that are not intended for direct manipulation by
a user, such as informative messages or labels.
This example creates a
Panel and adds several StaticText elements:
var dlg = new Window(‘dialog’, ‘Alert Box Builder’);
dlg.msgPnl = dlg.add(‘panel’, undefined, ‘Messages’);
dlg.msgPnl.titleSt = dlg.msgPnl.add(‘statictext’, undefined,
‘Alert box title:’);
dlg.msgPnl.msgSt = dlg.msgPnl.add(‘statictext’, undefined,
‘Alert message:’);
dlg.show();
EditText
Allows users to enter text, which is returned to the script when the dialog is
dismissed. Text in
EditText elements can be selected, copied, and pasted.
X Set the text property to assign the initial displayed text in the element, and read
it to obtain the current text value, as entered or modified by the user.
X Set the textselection property to replace the current selection with new text,
or to insert text at the cursor (insertion point). Read this property to obtain the
current selection, if any.
This example adds some
EditText elements, with initial values that a user can accept
or replace:
var dlg = new Window(‘dialog’, ‘Alert Box Builder’);
dlg.msgPnl = dlg.add(‘panel’, undefined, ‘Messages’);
dlg.msgPnl.titleSt = dlg.msgPnl.add(‘statictext’, undefined,
‘Alert box title:’);
dlg.msgPnl.titleEt = dlg.msgPnl.add(‘edittext’, undefined,
‘Sample Alert’);
dlg.msgPnl.msgSt = dlg.msgPnl.add(‘statictext’, undefined,
‘Alert message:’);
dlg.msgPnl.msgEt = dlg.msgPnl.add(‘edittext’, undefined,
‘<your message here>’, {multiline:true});
dlg.show();
Note the creation property on the second EditText field, where multiline:true
indicates a field in which a long text string can be entered. The text wraps to appear
as multiple lines.
Kommentare zu diesen Handbüchern