How does focus work in Flex?

I'm trying to figure out how the focus mechanism in Flex works. Here is an example of what I mean:

Suppose we have a simple web application that contains a custom component that extends Canvasand implements mx.managers.IFocusManagerComponent. This component overrides the methods focusInHandlerand focusOutHandlershows some feedback about what they are called (thinner or thicker border). This custom component also contains some Text.

Component Source :

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100" height="100" creationComplete="cc();" implements="mx.managers.IFocusManagerComponent">
<mx:Script>
    <![CDATA[
        import mx.containers.Canvas;
        import mx.controls.Text;
        import mx.controls.TextArea;
        import mx.core.UIComponent;
        import mx.managers.IFocusManagerComponent;

        public function cc():void
        {
            text = new Text;
            text.text = "123";
            addChild(text);

            setStyle("backgroundColor", "0xddddff");
            setStyle("borderColor", "0x000000");
            setStyle("borderThickness", 1);
            setStyle("borderStyle", "solid");
        }

        private var text:Text;

        override protected function focusInHandler(e:FocusEvent):void {
            trace("focusInHandler, currFocus: " + focusManager.getFocus());
            setStyle("borderThickness", 4);
        }

        override protected function focusOutHandler(e:FocusEvent):void {
            trace("focusOutHandler, currFocus: " + focusManager.getFocus());
            setStyle("borderThickness", 1);
        }
    ]]>
</mx:Script>
</mx:Canvas>

Here is the live version (with the original view): http://rafalrybacki.com/lab/focus_question/ . The application also has TextAreabelow Canvas- to facilitate manipulation of focus during testing.

Questions:

  • , ( focusInHandler), , (focusOutHandler) - ?

  • Text Canvas (focusInHandler) (focusOutHandler nevet called) - ?

, ? .

,

+5
1

. [ , , :]

-, Canvas FocusManager , , IFocusManagerComponent. Canvas IFocusManagerContainer, , , , IFocusManagerComponent, , , , , , flex sdk .

, FocusEvent . FocusEvents , , , .

. focusOut , uicomponents --- combobox UITextField Button, FocusOut FocusIn, . ( ) container.contains() focusManger.getFocus() ( ..), .

, , - , , , focusIn focusOut evt, , . ( flex sdk) , , IFocusManagerComponent IFocusManagerContainer. .

, . ,

+1

All Articles