Skip to content

Instantly share code, notes, and snippets.

@geraldyeo
Created November 9, 2010 04:26
Show Gist options
  • Save geraldyeo/668698 to your computer and use it in GitHub Desktop.
Save geraldyeo/668698 to your computer and use it in GitHub Desktop.
Automatically select all text on focus
titleTF.addEventListener(FocusEvent.FOCUS_IN, onFocusIn);
titleTF.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