How to programmatically move the Flex TextArea carriage to the end?

I am trying to move the cursor to Flex TextArea to the end after adding some text from my code. I looked through the reference documentation for TextArea and its underlying TextField, but there seems to be no method for this.

One approach I tried is to set focus to the text area and send the KeyUp KeyboardEvent with the key code event set to the Finish key, but that doesn't work.

Any ideas on how to do this?

Thanks.

+5
source share
6 answers

try it

textArea.selectionBeginIndex = textArea.length;
textArea.selectionEndIndex = textArea.length;
+8
source

, Spark , Flex 4.5, selectRange(anchorIndex, activeIndex)

+4

, , ,

textArea.setSelection(beginIndex, endIndex);

u beginIndex endIndex ( textArea.text.length) positon. , .

+2

, textarea

verticalScrollPosition : Number
textArea.verticalScrollPosition(i);
0

@Paul Stewart verticalScrollPosition - , , , :

var newPosition:NUmber = 1;
textArea.verticalScrollPosition = newPosition;

The advantage of using this element over selectBeginIndex / selectionEndIndex is that you do not need to install foucus.

0
source

Just add the following code after adding text to TextArea:

textArea.verticalScrollPosition = textArea.maxVerticalScrollPosition;
0
source

All Articles