01-01-2011 06:09 PM
Does anyone know of a method I can call on TextInput focus which will set the cursor's position or select certain text within the input field? I'm trying to get the cursor to always start typing at the end of pre-filled text.
I've tried these but they don't seem to be valid methods for TextInput (I didn't expect them to work because they are not in the documentation, but it was worth a try):
Any help would be greatly appreciated!
Thanks to everyone in this forum for all they great posts! They have really helped answer a lot of my questions.
Solved! Go to Solution.
01-01-2011 06:21 PM
you have the right idea but instead of applying the setSelection method on your TextInput object, you need to apply it to the inner textField property reference to the TextField object inside.
here is a sample code from an older thread that selects all the text in a TextInput object:
public class TextInputTest extends Sprite
private var myInput:TextInput;
public function TextInputTest()
// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
myInput = new TextInput();
var newBtn:LabelButton = new LabelButton();
newBtn.label = "Click Me";
private function selectMyText(e:MouseEvent):void
stage.focus = myInput;
this line is where it does the trick:
the first parameter is the start selection point and the last parameter is how much of it is to be selected.
here is the link to the thread the code is from for more detail:
hope that helps. good luck!