Skip to main content
Inspiring
January 6, 2008
Question

Control cursor position in TextInput() ?

  • January 6, 2008
  • 2 replies
  • 2286 views
Hi --

I would like to know if it is possible to control the position of the cursor
in a text input in Flash CS 3 using AS 3.0.

I know how to figure out where the cursor is by using the
selectionBeginIndex property. However, this and the selectionEndIndex are
read only. Basically I am manipulating text as the user enters it and
sometimes I add a character but the cursor does not automatically move to
the end of the input box and that is what I am trying to do.

Thanks

Rich


This topic has been closed for replies.

2 replies

Inspiring
January 7, 2008
Hi --

That works! Thank you so much!

Rich

"Craig Grummitt" <webforumsuser@macromedia.com> wrote in message
news:flrptl$3uf$1@forums.macromedia.com...
> positioning the cursor in flash can be a little tricky and sometimes
> temperamental, but you should be able to control where the cursor is with
> setSelection, with both beginIndex and endIndex set to the end of the
> input box
> eg:
> testBox.setSelection(testBox.text.length,testBox.text.length);
>
> You may also need to first set the focus to the text box, if the focus may
> be
> elsewhere. If your 'text input' is a TextField of type 'input text', then
> set
> focus through the stage object:
>
> stage.focus=testBox;
> testa.setSelection(testBox.text.length,testBox.text.length);
>
> if you're talking about a TextInput component, use its built in setFocus
> method:
>
> testBox.setFocus();
> testBox.setSelection(testBox.text.length,testBox.text.length);
>


Craig Grummitt
Inspiring
January 6, 2008
positioning the cursor in flash can be a little tricky and sometimes temperamental, but you should be able to control where the cursor is with setSelection, with both beginIndex and endIndex set to the end of the input box eg:
testBox.setSelection(testBox.text.length,testBox.text.length);

You may also need to first set the focus to the text box, if the focus may be elsewhere. If your 'text input' is a TextField of type 'input text', then set focus through the stage object:

stage.focus=testBox;
testa.setSelection(testBox.text.length,testBox.text.length);

if you're talking about a TextInput component, use its built in setFocus method:

testBox.setFocus();
testBox.setSelection(testBox.text.length,testBox.text.length);