2 Replies Latest reply on Aug 6, 2009 9:22 PM by mfsiddiq

    FocusOut Issue in AdvancedDataGrid with ItemRenderers




         I am having issue with FocusOut Event.I have an ADG with TextInput as my renderer in most of the columns.I have added a FocusOut Event as listener on my textInput Renderer component.FocusOut Event gets triggered whenever my focus moves away from the TextInput to any blank areas on the ADG and my listener function gets called perfectly,But whenever i move my focus from one textInput Renderer component to another TextInput Renderer component(either in the same column or a different column),FocusOut Event Listener function is called twice as a result i am getting wrong results.It is called once for the previous Focused Out textInput and once for the new Focused In Textinput.How do i resolve this issue.




        • 1. Re: FocusOut Issue in AdvancedDataGrid with ItemRenderers
          Kenny Yates



          The way around this I have implemented for a few of my clients in just such a scenerio was to add the event listener for the FocusOut event ONLY in the FocusIn function for each individual TextInput renderer.



          Each TextInput Renderer has on it's creation complete a FocusIn event listener setup.


          When that FocusIn response function fires, in that same function add the event listener for FocusOut ONLY for that renderer instance.


          One the FocusOut reponse function for remember to REMOVE the FocusOut event for that renderer instance that way it will only fire when you FocusIn to the component.




          <?xml version="1.0" encoding="utf-8"?>
          <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300"
                  import mx.controls.Alert;
                  private function initRenderer():void
                      tiMyInput.addEventListener(FocusEvent.FOCUS_IN, handleFocusIn, false, 0, true);
                  private function handleFocusIn(event:FocusEvent):void
                      tiMyInput.addEventListener(FocusEvent.FOCUS_OUT, handleFocusOut, false, 0, true);
                  private function handleFocusOut(event:FocusEvent):void
                      Alert.show("focused out and removed listener");
                      tiMyInput.removeEventListener(FocusEvent.FOCUS_OUT, handleFocusOut);
              <mx:TextInput id="tiMyInput"/>



          Kenny Yates


          1 person found this helpful
          • 2. Re: FocusOut Issue in AdvancedDataGrid with ItemRenderers
            mfsiddiq Level 1

            Thank You Yates.Your response was really useful in resolving my issue