-
Happy FK'er
Passing focus
Hi guys,
I had a question regarding the 'passing' of focus.
I have a class (more like a component) which contains a TextField.
If I give 'focus' to the class, how can I send the focus to the TextField (which is private to the class containing it, like a component).
To elaborate, I'm not sure focus occurs on 'just the endpoint' or 'to a branch'.
If focus is just given to the endpoint, how does my component disregard having focus and gives the focus to the endpoint?
If focus is a given to a branch, what if focus is given (via mouse click) to the text field? I would have an event listener catch the focus event which shares the focus with the parent, but the problem there is once the parent has focus it shares the focus with the child which creates a loop.
Could anyone shed light on this? Perhaps give me some... focus? heh
Regards,
TheWaste
"Good lord, you're wasting thousands of dollars worth of Interferon!"
"... and you're Interferon with our good time!"
-
Total Universe Mod
Not exactly sure what you're asking but you might look up tabChildren, tabEnabled and tabIndex. Also look into event bubbling and event phases.
-
Senior Member
Even if your component is getting focus, as long as the textfield has an event listener, it can listen to the focusevent:
myComponent.addEventListener (FocusEvent.FOCUS_IN, focusInHandler);
private function focusInHandler (event:FocusEvent):void
{
var target:CustomComp = CustomComp(event.target);
trace ("focusInHandler: " + target.name);
}
Inside of your your component class you have this:
myText.addEventListener(MouseEvent.CLICK, clickHandler);
private function clickHandler (event:Event):void
{
var target:TextField = TextField(event.target);
stage.focus = target;
}
- The right of the People to create Flash movies shall not be infringed. -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|