Jun 18, 2009

Solving the wmode keyboard bug in Firefox (AS3)

The Firefox team has embarrasingly been saying (for years) that they are working on solving their problems with keyboard focus on embedded flash objects with wmode set to either 'transparent' or 'opaque'.

See details:
http://forum.sephiroth.it/showthread.php?t=9232
http://timconfessions.blogspot.com/2008/04/firefox-wmodetransparent-bug.html
http://lists.macosforge.org/pipermail/webkit-unassigned/2008-September/084474.html

The list goes on and hopes are low. There has been some dirty quickfixes circulating but I grew tired and wrote a more robust solution for AS3.

Embed the following in your class, assign it to your inputField and... enjoy.

Download Flex Project Archive

 0)? input.text.substring(input.selectionEndIndex, input.text.length) : "";

     // Enter the codes to change here
     // Below is Swedish keyboard
     switch (event.text)
     {
      case "2" : event.text = "@"; break;
      case "3" : event.text = "£"; break;
      case "4" : event.text = "$"; break;
      case "5" : event.text = "€"; break;
      case "6" : event.text = "6"; break;
      case "7" : event.text = "{"; break;
      case "8" : event.text = "["; break;
      case "9" : event.text = "]"; break;
      case "0" : event.text = "}"; break;
      case "+" : event.text = "\\"; break;
      case "<" : event.text = "|"; break;
      default : break;                     
     }

     input.text = startText + event.text + endText;
     input.setSelection(input.selectionBeginIndex + 1, input.selectionBeginIndex + 1);
    }
    catch (error:Error)
    {
     trace(error.getStackTrace());
    }
   }
  }
 }
}

1 comment:

Anonymous said...

So yesterday I was thinking for starting my own home business and to obtain any affiliate websites I really don't know if it is better to get one myself or obtain some already ready made affiliate websites. I just discovered website
[url=http://www.home-businessreviews.com/Turnkey-Affiliate-Websites.html]website affiliate[/url] and here was two reviews about these sites but I yet haven't made decision what to do. Maybe there some members who can give some opinion for sites reviewed at that website?
http://www.home-businessreviews.com/Turnkey-Affiliate-Websites.html