So i need to get the id of a keyboard event for buttons and textInput. Depending on the ID of the component, the focus is set. When the focus is on a button and an event is dispatch, the event.target.id is the name of the button that dispathed the event but when the textInput dispatches the event, the event.target.id is not the id of the textInput component. Is there a way i can get the ID of the textInput from the the dispatched event. Please help me out.
Here is a snipit of my code:
In the script block of the main application mxml file
protected function handle_keypress(event:KeyboardEvent):void
var key:Number = event.keyCode;
var pattern:String = event.target.id;
trace('id is: ' + pattern); //output for button is btn1, output for textInput is textDisplay instead of txtipt1
mxml code in main application
That did not work. when i typed in focusManager.getFocus().id id did not come up on code complete. I also had an error that said access of undefinted property on id.
So i tried focusManager.getFocus() (without the id). It printed out a long string that looked like the uid.
One the console is read:
mainapp.group1.......................txtipt1 //txtipt1 is the textinput id.
Do you have any other suggestions to get the textInput id? Can i use a regular experssion or a build-in function to do that?
Thanks for your help
Yes, code complete won’t work there. Try UIComponent(focusManager.getFocus()).id