Skip to content

Instantly share code, notes, and snippets.

@adeolaawoyemi
Created June 19, 2012 13:50
Show Gist options
  • Save adeolaawoyemi/2954331 to your computer and use it in GitHub Desktop.
Save adeolaawoyemi/2954331 to your computer and use it in GitHub Desktop.
Automatically select all text in a TextField when user clicks inside it
my_tf.addEventListener(FocusEvent.FOCUS_IN, onFocusIn);
my_tf.addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
function onFocusIn(event:FocusEvent):void {
setTimeout(event.target.setSelection, 50, 0, event.target.text.length);
}
function onFocusOut(event:FocusEvent):void {
event.target.setSelection(0,0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment