quick note

problem:

The livedocs suggest that every UIComponent has automatically set event listeners for keyUp (and keyDown) events. So, I expected that it’s enough to override this method to make
some action on key-click. But that isn’t the case.. Instead – nothing happens.

resolvent:

The UIComponent constructor has the logic


if (this is IFocusManagerComponent)
{
addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
}

In order to receive keyboard events, your component must implement IFocusManagerComponent:

“The base implementations of this interface are in the UIComponent class, but UIComponent does not implement the full IFocusManagerComponent interface since some UIComponents are not intended to receive focus. Therefore, to make a UIComponent-derived component be a valid focusable component, you simply add “implements IFocusManagerComponent” to the class definition.”

If you’re writing an MXML component, you declare that it implements an interface with the tag attribute


implements="mx.managers.IFocusManagerComponent"

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Hello world

Hi,我是Tang Bin,finalbug.org是我的个人站点。这里有更多关于我的内容。English readers please click here to learn more about me and this site.

Categories