A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Passing focus

  1. #1
    Happy FK'er TheWaste's Avatar
    Join Date
    Dec 2003
    Location
    Here
    Posts
    779

    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!"

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Not exactly sure what you're asking but you might look up tabChildren, tabEnabled and tabIndex. Also look into event bubbling and event phases.

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center