4 Replies Latest reply on Apr 26, 2010 9:42 AM by puddytat5000

    TextInput focus after alert closed with enter key

    puddytat5000

      Hi,

       

      The following is a problem that was encountered by a poster at http://livedocs.adobe.com/flex/3/langref/mx/controls/Alert.html. I have also experienced the same problem so I thought I would repost it here to see if anyone could help:

       

       

       

      1. When clicking OK button of popup by mouse, focus changes normally to  textInput.  
      2. When pressing OK button by Enter key, focus changes  to disabled button itself. 
      Can anyone explain what is happening  here. 
        
      <?xml version="1.0" encoding="utf-8"?> 
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> 
        <mx:Script> 
              <![CDATA[ 
          import mx.controls.Alert; 
          import  mx.events.CloseEvent; 
           
          private function  alertHandler(event:CloseEvent):void { 
            
               if (  event.detail == Alert.OK ){ 
            button1.enabled = false; 
             
            text1.setFocus(); 
            text1.drawFocus(true);    
                } 
          } 
           
          private function  btnClick(event:Event):void { 
               Alert.show("Hello!", "", Alert.OK  | Alert.CANCEL, this, alertHandler); 
          }  
             ]]> 
        </mx:Script> 
        <mx:Button  id="button1" label="Alert" click="btnClick(event)"/>  
        <mx:TextInput  id="text1"/> 
         
      </mx:Application>