Adobe InDesign CS6 (8.0) Object Model JS: EditText

InDesign CS6

Class

EditText

 

An editable text field that the user can select and change.

Calls the onChange() callback if the text is changed and the user types Enter or the control loses focus, or if its notify() method is called. Calls the onChanging() callback when any change is made to the text. The textselection property contains currently selected text.

QuickLinks

addEventListener, dispatchEvent, hide, notify, onActivate, onChange, onChanging, onDeactivate, onDraw, onShortcutKey, removeEventListener, show

Hierarchy

Object
EditText

Properties

PropertyTypeAccessDescription
activeBoolean r/wTrue if this element is active.
An active control is the one with keyboard focusóthat is, the one that accepts keystrokes, or in the case of a Button, is selected when the user types Return or Enter in Windows, or the space bar in Mac OS.
alignmentString r/w The alignment style for this element. If defined, this value overrides the alignChildren setting for the parent container.
This can be a single string, which indicates the alignment for the orientation specified in the parent container, or an array of two strings, indicating both the horizontal and vertical alignment (in that order). Allowed values depend on the orientation value of the parent container. They are not case sensitive.
•  For orientation=row:top, bottom, fill
•  For orientation=column: left, right, fill
•  For orientation=stack:top, bottom, left, right, fill
boundsBounds r/wThe boundaries of the element, in parent-relative coordinates.
Setting an element's size or location changes its bounds property, and vice-versa.
charactersNumber (min: 0) r/wA number of characters for which to reserve space when calculating the preferred size of the element.
childrenArray of Object readonlyAn array of child elements.
enabledBoolean r/wTrue if this element is enabled.
An enabled element can accept input, according to its type. When false, control elements do not accept input, and all types of elements have a dimmed appearance.
graphicsScriptUIGraphics readonly The graphics object that can be used to customize the element's appearance, in response to the onDraw() event.
helpTipString r/wThe help text that is displayed when the mouse hovers over the element.
indentNumber (min: 0) r/wThe number of pixels to indent the element during automatic layout.
Applies for column orientation and left alignment, or row orientation and top alignment.
justifyString r/wThe text justification style. (default: left)
One of left, center, or right. Justification only works if this value is set on creation of the element.
locationPoint r/wThe upper left corner of this element relative to its parent.
The location is defined as [bounds.x, bounds.y]. Setting an element's location changes its bounds property, and vice-versa.
maximumSizeDimension r/w The maximum height and width to which the element can be resized.
minimumSizeDimension r/w The minimum height and width to which the element can be resized.
parentObject readonlyThe parent element.
preferredSizeDimension r/wThe preferred size, used by layout managers to determine the best size for each element.
If not explicitly set by a script, value is established by the UI framework in which ScriptUI is employed, and is based on such attributes of the element as its text, font, font size, icon size, and other UI framework-specific attributes.A script can explicitly set this value before the layout manager is invoked in order to establish an element size other than the default.
propertiesObject r/wAn object that contains one or more creation properties of the container (properties used only when the element is created).
Creation properties of an EditText object can include:
•  multiline: When false (the default), the control displays a single line of text. When true, the control displays multiple lines, in which case the text wraps within the width of the control.
•  readonly: When false (the default), the control accepts text input. When true, the control does not accept input but only displays the contents of the text property.
•  noecho: When false (the default), the control displays input text. When true, the control does not display input text (used for password input fields).
•  enterKeySignalsOnChange: When false (the default), the control signals an
event when the editable text is changed and the control loses the keyboard focus (that is, the user tabs to another control, clicks outside the control, or types Enter). When true, the control only signals an onChange() event when the editable text is changed and the user types Enter; other changes to the keyboard focus do not signal the event.
shortcutKeyString r/w The key sequence that invokes the onShortcutKey() callback for this element (in Windows only).
sizeDimension r/wThe current dimensions of this element.
Initially undefined, and unless explicitly set by a script, it is defined by a LayoutManager . A script can explicitly set size before the layout manager is invoked to establish an element size other than the preferredSize or the default size, but this is not recommended. Defined as [bounds.width, bounds.height]. Setting an element's size changes its bounds property, and vice-versa.
textString r/wThe current text displayed in the field, a localizable string.
textselectionString r/wThe currently selected text, or the empty string if there is no text selected.
Setting the value replaces the current text selection and modifies the value of the text property. If there is no current selection, inserts the new value into the text string at the current insertion point. The textselection value is reset to an empty string after it modifies the text value. Note that setting the textselection property before the elementís parent Window exists is an undefined operation.
typeString readonlyThe element type; "edittext".
visibleBoolean r/wTrue if this element is shown, false if it is hidden.
When a container is hidden, its children are also hidden, but they retain their own visibility values, and are shown or hidden accordingly when the parent is next shown.
windowWindow (SUI) readonlyThe window that this element belongs to.
windowBoundsBounds readonlyThe bounds of this element relative to the top-level parent window.

Methods

Events

void onActivate ()
An event-handler callback function, called when the element acquires the keyboard focus.
Called when the user gives the control the keyboard focus by clicking it or tabbing into it.

void onChange ()
An event-handler callback function, called when the content of the element has been changed
The handler is called only when the change is completeóthat is, when focus moves to another control, or the user types Enter. The exact behavior depends on the creation parameter enterKeySignalsOnChange;see the
property.

void onChanging ()
An event-handler callback function, called when the content of the element is in the process of changing
The handler is called for each keypress while this control has the input focus.

void onDeactivate ()
An event-handler callback function, called when the element loses the keyboard focus.
Called when the user moves the keyboard focus from the previously active control to another control.

void onDraw ()
An event-handler callback function, called when the window is about to be drawn.
Allows the script to modify or control the appearance, using the controlís associated ScriptUIGraphics object. Handler takes one argument, a DrawState object.

void onShortcutKey ()
An event-handler callback function, called when the element's shortcutKey sequence is typed in the active window.
In Windows only.

Instances

Boolean addEventListener (eventName: String, handler: Function[, capturePhase: Boolean=false])
Registers an event handler for a particular type of event occuring in this element.

ParameterTypeDescription
eventNameStringThe name of the event.
Event names are listed in the JavaScript Tools Guide.
handlerFunctionThe function that handles the event.
This can be the name of a function defined in the extension, or a locally defined handler function to be executed when the event occurs. A handler function takes one argument, the UIEvent object.
capturePhaseBooleanWhen true, the handler is called only in the capturing phase of the event propagation. (default: false)
Default is false, meaning that the handler is called in the bubbling phase if this object is an ancestor of the target, or in the at-target phase if this object is itself the target.

Event dispatchEvent ()
Simulates the occurrence of an event in this target.
A script can create a UIEvent object for a specific event and pass it to this method to start the event propagation for the event.

void hide ()
Hides this element.

void notify ([eventName: String])
Sends a notification message, simulating the specified user interaction event.

ParameterTypeDescription
eventNameStringThe name of the control event handler to call.
One of: onClick, onChange, onChanging. By default, simulates the onChange event for an edittext control, an onClick event for controls that support that event. (Optional)

Boolean removeEventListener (eventName: String, handler: Function[, capturePhase: Boolean=false])
Unregisters an event handler for a particular type of event occuring in this element.
All arguments must be identical to those that were used to register the event handler.

ParameterTypeDescription
eventNameStringThe name of the event.
handlerFunctionThe function that handles the event.
capturePhaseBooleanWhether to call the handler only in the capturing phase of the event propagation. (default: false)

void show ()
Shows this element.
When a window or container is hidden, its children are also hidden, but when it is shown again, the children retain their own visibility states.

Jongware, 28-Apr-2012 v3.0.3hContents :: Index