4 Replies Latest reply: Jul 4, 2013 7:39 AM by crozyo RSS

    Auto focus textinput...


      Before I ask something, sorry for my no good english.


      I have made a game editor with Air sdk and flex components.

      Today I got a complaint from the designer who using the game editor which I've given.

      The Game editor consist main Window and sub mx::TitleWindow

      and the sub titlewindow have two mx:NumericStepper.

      The problem is when focus in the sub titlewindow, the NumericStepper always focus In.(the cursor wrapped the value text in editable)


      The graphic designer want to control other component in the sub titlewindow with keyboard Input, but as always focus-in at first for NumericStepper, always need to click other componentto remove the focus of the NumericStepper...


      So, I try to stage.focus set null when the sub Titlewindow focus-in.. but It doesn't work like what I need.

      The best result what I want  is Do not auto focus the textInput when the parent of it is focus-in.

      (Actually the textInput always focus-in If it have been set focus-in ever before)


      I really want to give me a good solution or comment...


      Thank you to read my bad English question.

        • 1. Re: Auto focus textinput...
          Flex harUI Adobe Employee

          In Flex, containers like TitleWindow do not get focus, only controls like NumericStepper.


          By default, no Flex SDK code should be setting focus to the NumericStepper, so it seems like some code in your app may be doing it.


          If you can post a small complete test case, we can try to help.



          • 2. Re: Auto focus textinput...
            crozyo Community Member

            Thank you for reply.

            I make simple sample code having similiar situation.

            The APP have a titleWindow containing NumericStepper and the NumericStepper of the App.


            At first, I clicked the TextInput of NumericStepper of the TitleWindow to edit the value. and Click another NumericStepper of the APP.

            and  I click the TitleWindow of the TitleWindow not NumericStepper, then, the NumericStepper is focused automatically.

            I just want to the NumericStepper of the titleWindow not having focus while I click the TitleWindow.


            thank you.


            <?xml version="1.0" encoding="utf-8"?>
            <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                    width="100%" height="100%"
              <!-- Place non-visual elements (e.g., services, value objects) here -->
               import mx.containers.TitleWindow;
               import mx.containers.VBox;
               import mx.controls.NumericStepper;
               import mx.core.FlexGlobals;
               import mx.core.UIComponent;
               import mx.events.FlexEvent;
               import mx.managers.PopUpManager;
               protected function OnCreateComplete(event:FlexEvent):void
                var defaultBox:VBox = new VBox();
                defaultBox.width = 300;
                defaultBox.height = 300;
                var myStepper1:NumericStepper = new NumericStepper();
                myStepper1.width = 50;
                myStepper1.height = 30;
                var titleWnd:TitleWindow = TitleWindow( PopUpManager.createPopUp(UIComponent(FlexGlobals.topLevelApplication) , TitleWindow, false) );
                titleWnd.title = "SubTitle";
            <mx:VBox width="500" height="500" backgroundColor="0x773333">
              <mx:NumericStepper width="50" height="30" />

            • 3. Re: Auto focus textinput...
              Pooja Kuber Community Member

              Try to set the focusEnabled property to false.


              myStepper1.height = 30;

              myStepper1.focusEnabled = false;



              This will only focus the stepper when user will enter the value in it and not on any other events.


              Hope this will help you. 


              Thanks and Best regards,

              ---------------------------------------------------------------------- -----------------

              Pooja Kuber | pkuber@infocepts.com | www.infocepts.com

              ---------------------------------------------------------------------- -----------------

              • 4. Re: Auto focus textinput...
                crozyo Community Member

                I really so thank you for your answer...

                I have mistook the usage of 'focusEnabled' for  enable edit... 

                anyway, I would like to say thank again Pooja Kuber and Flex hardUI.