How do you programmatically move the caret of a Flex TextArea to the end?

Akinwale picture Akinwale · Feb 2, 2009 · Viewed 9.1k times · Source

I'm trying to move the caret in a Flex TextArea to the end after appending some text from my code. I've looked through the reference documentation for TextArea and its underlying TextField but it appears there is no method provided to handle this.

One approach I've tried is to set focus to the text area and dispatch a KeyUp KeyboardEvent with the event's key code set to the "End" key, but this doesn't work.

Any ideas on how to do this?

Thanks.

Answer

Chetan S picture Chetan S · Feb 2, 2009

Try this

textArea.selectionBeginIndex = textArea.length;
textArea.selectionEndIndex = textArea.length;