5 Replies Latest reply on Jun 24, 2010 10:26 PM by Flex harUI

    Focusable Container

    UbuntuPenguin Level 4

      TL;DR I need to make a container with a blue highlight during the "focus" state. Like the border when a TextInput gains focus.

      Hello Everyone ,

      I need to make a container ( BorderContainer , SkinnableContainer ) with a blue highlight during the "focus" state.  I've tried implementing IFocusManagerContainer on a BorderContainer and setting the style "borderVisible" as true in the drawFocus(boolean) function.  But no dice.  My other comical attempt was setting a focusSkin on the container , and then setting the "focusEnabled" to true.  Still no luck.

       

      By focus I mean click , but not quite the same behavior seeing how only one of these components can have the focus at any given time.

        • 1. Re: Focusable Container
          Flex harUI Adobe Employee

          You want to implement IFocusManagerComponent.

          1 person found this helpful
          • 2. Re: Focusable Container
            UbuntuPenguin Level 4

            That's what I'm doing , but the behavior is confusing.   Here is the code"

             

               import mx.managers.FocusManager;
               override public function drawFocus(isFocused:Boolean):void
               {
                if( isFocused == true )
                {
                 stroke.alpha = 1;
                }
                else
                {
                 stroke.alpha = 0;
                }
               }

               protected function bordercontainer1_clickHandler(event:MouseEvent):void
               {
                focusManager.setFocus( this );
               }

             

            So what do you think happens when the bordercontainer (bordercontainer1_clickHandler) is clicked ?  If you thought the border container received focus you were wrong.  The drawFocus function is called , but the parameter "isFocused" is set to false ?  So in some weird way , setting the focus to the bordercontainer actually removes the focus ?

            • 3. Re: Focusable Container
              Flex harUI Adobe Employee

              Maybe some other IFocusManagerComponent proeprties aren't set up correctly.

              You shouldn't have to use a clickhandler to get focus.  The FocusManager

              should do it automatically if the properties are set up.

              1 person found this helpful
              • 4. Re: Focusable Container
                UbuntuPenguin Level 4

                So you're saying if set the properties up correctly (setFocus , drawFocus )  , my container will automatically receive focus when clicked ?  Truth be told , all I want is an image that has a border light up and gains focus when clicked.  As always thanks.

                • 5. Re: Focusable Container
                  Flex harUI Adobe Employee

                  Yeah, you can look at our current components.  They don't have lots of focus

                  related code in them.  To get focus, you have to implement

                  IFocusManagerComponent which Image does not so if you're wrapping it in a

                  BorderContainer then BorderContainer should implement

                  IFocusManagerComponent, have focusEnabled=true, tabFocusEnabled=true, and

                  hasFocusableChildren=false.

                   

                  -Alex