RSS LinkedIn Twitter

Spark IFocusManagerContainer Group (a tab enabled popup)

December 15th, 2010 Categories: Actionscript, Flex 4, Flex Builder, Languages

I finished my final Flex 3 project a couple months ago and have finally been able to start digging into Flex 4 for my current projects. There are two in particular that involve a number of input-type popups.

The first thing I noticed about these popups (which were based on either Group or VGroup) was that tabbing between controls seemed to be disabled. I had enough of that yesterday and so I did some research as to what was going on.

It turns out that there’s an interface, IFocusManagerContainer that needs to be implemented in order for the popup to be given a FocusManager. At least that’s the way I understood it– take a look at the constructor in this code.

Container, Menu, and SkinnableContainerBase all implement this interface, so had I used one of those as the base of my popup, it would have worked as expected. Group doesn’t implement this interface, and that was my problem.

Using Flash Builder I created a component that extended Group and implemented IFocusManagerContainer, and it created the following methods for me (which I assume are the required methods for the IFocusManagerContainer interface:

public function get defaultButton():IFlexDisplayObject { return null; }
public function set defaultButton(value:IFlexDisplayObject):void { }

The documentation on IFocusManagerContainer says regarding the defaultButton: “This property is managed by Flex containers; do not set it directly to the default button.” Interesting.

Using the generated class as the base class for my popups allowed tabbing to work as expected. Here’s the entire class in case you’re interested:

package com.googolflex.containers {
  import mx.core.IFlexDisplayObject;
  import mx.managers.IFocusManagerContainer;
  import spark.components.Group;
  public class MyContainer extends Group implements IFocusManagerContainer {
    public function MyContainer() {
      super();
    }
    public function get defaultButton():IFlexDisplayObject { return null; }
    public function set defaultButton(value:IFlexDisplayObject):void { }
  }
}
Tags:

2 Responses to “Spark IFocusManagerContainer Group (a tab enabled popup)”

  1. Bob
    July 18th, 2011 at 14:50
    1

    Thanks for this, so simple but it solved my problem with over 20 spark popup ‘panels’….

  2. NotBob
    February 21st, 2013 at 15:34
    2

    In FB 4.0, I created the class but had to comment out the super statement.

    1007:A super statement can only be used inside class instance constructors.

    When I changed my pop from Group to the new Class, I got the errors:

    Could not resolve (s:filters) to a component implementation
    Could not resolve (s:states) to a component implementation

    Not using the new class, and having group implement the IFocusManagerContainer, I get the following:

    Description Resource Path Location Type
    1044: Interface method get defaultButton in namespace mx.managers:IFocusManagerContainer not implemented by class…

Leave a Comment

*