Name
Selection.getCaretIndex( ) Method — retrieve the index of the insertion point
Availability
Flash 5
Synopsis
Selection.getCaretIndex( )
Returns
The index of the insertion point in the current text field. If no text field has keyboard focus, it returns -1. If the text field with focus is empty, it returns 0.
Description
The getCaretIndex( ) method indicates the
insertion point (i.e., the location of the cursor) in a text field.
The cursor appears as an I-beam when a text field has keyboard focus.
Use setSelection( ) to set the location of the
insertion point.
Example
Because getCaretIndex( ) returns -1 when no text
field has focus, we may determine whether any field has focus by
checking whether getCaretIndex( ) is equal to
-1, as follows:
if (Selection.getCaretIndex( ) == -1) {
trace("No field has focus");
}See Also
Selection.setSelection( )
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access