Fix: Tabbing does not work on textfield

Posted on December 29, 2009

0


By default a TextField is visible for tabbing. In some cases, however, Flash simply completely ignores the TextField. This is a weird and unexplainable bug and can occur when you create text fields via code.

I have spent some hours getting around this problem.

Here is a pseudo-sample of my old code:

var myTxtFld:TextField=new TextField();
myTxtFld.width = 100;
myTxtFld.height=20; myTxtFld.x=20;
myTxtFld.y=40;
myTxtFld.type="input"
myTxtFld.tabIndex=myTabIndex
myTabIndex+=1
myTxtFld.tabEnabled = true;

This should work, right?
Wrong: not in the case of this bug in Flash.

Apparently tabEnabled is ignored when applied later. The fix (after going though a lot of other possible causes) is this:

var myTxtFld:TextField=new TextField();
myTxtFld.tabEnabled = true;

myTxtFld.width = 100;
myTxtFld.height=20; myTxtFld.x=20;
myTxtFld.y=40;
myTxtFld.type="input"
myTxtFld.tabIndex=myTabIndex
myTabIndex+=1
Advertisements
Posted in: Workarounds