Skip navigation
jkorona
Currently Being Moderated

tabEnabled property issue.

Aug 31, 2010 12:20 PM

I have problem with changing value of tabEnabled property in runtime. My goal is to prevent user setting focus on components by tab key in some specific situations.

I will start from sample code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
     
     <mx:Script>
          <![CDATA[
               
               [Bindable]
               private var flag : Boolean = false;
               
          ]]>
     </mx:Script>
     
     <mx:Button/>
     <mx:ComboBox tabEnabled="{flag}"/>
     <mx:ComboBox tabEnabled="{flag}"/>
     <mx:ComboBox tabEnabled="{flag}"/>
     <mx:ComboBox tabEnabled="{flag}"/>
     <mx:Button>
          <mx:click>
               <![CDATA[
                    flag = !flag;
               ]]>
          </mx:click>
     </mx:Button>
     
</mx:Application>

 

 

If initially value of tabEnabled is set to true, then I can change it in runtime many times without any problems. But if I set initially value of tabEnabled to false then even if I change it to true in runtime, component behaves as if it had this property turned off - can't set focus using tab key.

Maybe solution for this problem is very simple, but actually I have no idea how to solve it, so I'm looking forward on your help.

BTW. I am using Flex SDK 3.5 FP 10.1.

 
Replies
  • Currently Being Moderated
    Aug 31, 2010 12:33 PM   in reply to jkorona

    Looks like a bug.  File it in bugs.adobe.com/jira.  I'd say the workaround

    is probably to initialize it to true and set it back to false in

    applicationComplete handler.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 31, 2010 1:41 PM   in reply to jkorona

    I don't understand what you were trying to do.  Did my suggestion not work?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 31, 2010 2:57 PM   in reply to jkorona

    I think you can just add them with tabEnabled=true and set it to false on

    creationComplete.  It shouldn't require overriding tabEnabled

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 31, 2010 3:54 PM   in reply to jkorona

    CreationComplete should be sufficient.  TabEnabled should default to true on

    these components so the component should get added to the FocusManager in

    the call to addChild, then you would set it to false on creationComplete.

     

    Maybe a helper function like

     

    Function addTabDisbledComponent(parent:DisplayObjectContainer,

    component:IUIComponent):void

    {

        component.addEventListener(FlexEvent.CREATION_COMPLETE,

    tabDisableHandler);

        parent.addChild(component);

    }

     

    Function tabDisableHandler(event:Event):void

    {

        event.target.removeEventListener(FlexEvent.CREATION_COMPLETE,

    tabDisableHandler);

        event.target.tabEnabled = false;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2013 4:42 AM   in reply to jkorona

    OMG!!

    I can't believe such an obvious but still haven't been fixed 3 years after it was reported.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points