flashactionscript-3actionscriptfocusmanager

How to create multiple tab loops in AS3 by using fl.managers.FocusManager?


I want to create a tab-enabled popup window in an AS3 Air project. Currently, when I press tab several times, the focus goes through all the components in my popup window and then starts focusing the buttons and TextFields from the components that are behind the popup. I have tried to solve this problem in two ways, but none of them worked. I will explain both of the methods here

  1. The official method
    I have read adobe's documentation from here and it describes what I should do in my case like this:

    "Each modal Window component contains an instance of the FocusManager, so the controls on that window become their own tab set. This prevents a user from inadvertently navigating to components in other windows by pressing the Tab key. " But I still don't understand how to use the FocusManager.

    • I have tried creating an instance of the FocusManager in each of my view component classes by putting the code below in the constructor, but it didn't work:

    _focusManager = new FocusManager(this);

    • What do they mean by "modal Window component" ?
  2. The workaround method
    Another thing I've tried is to manually set the tabEnabled property to true or false on each button and TextField when the Parent component dispatches a FOCUS_IN or FOCUS_OUT event. This worked on a simple example that I created on a new flash file, but it doesn't work on my large project, and I don't know how to debug it. However I would be very glad to dump this and go back to method number 1.

Has anyone encountered these problems before? Have you used multiple tab cycles in any other way? Any hint is welcome right now, because I've been wasting too much time on this problem. Thank you [Edit] I was getting a lot of views for this question, but no relevant answers, so I edited it and tried to simplify it


Solution

  • I ended up writing my own FocusManager which does what I need. It turned out to be easier than I initially thought. I'm sorry to say that I can't post the code here, but I'll give you a short description of what I did and hope that it helps:

    I took a peek into the mx.managers.FocusManager code, and from what I saw, most of their effort was put into handling all the possible cases where the FocusManager might be used, this is why it's so long and complicated. I can only assume that fl.managers.FocusManagers looks similar. I bet that mine still has a lot of problems, and it isn't as portable as the ones from Adobe, but it's very simple and it does what I need it to do.

    I would still like to see some guidelines on how to correctly use the existing FocusManager.