How to control cursor (carat) position in TextInput in Flex 4.5

PeterM picture PeterM · Sep 15, 2011 · Viewed 7.1k times · Source

I need to handle diagraphs and then convert them on the fly to the proper unicode representation. For example when the user types in:

Sx

My app needs to replace it with:

Ŝ

Now, I've been able to do the replacement no problem. The issue though is that once I've done the replacement, the cursor goes to the beginning of the textbox rather than the end. As I'm trying to update the user's text on the fly, this obvious doesn't work.

How can I get it so that once I replace the text in the TextInput box, the cursor is on the right hand side rather than the left?

Answer

PeterM picture PeterM · Sep 15, 2011

Found a solution.

All you have to do is instead of updating the whole text, wipe the current content and then use:

textInput.appendText()

Hopefully this will help someone else :)