Workaround for wmode bug with text input

UPDATE: problem greatly solved since Firefox 3.5, we now have to add an exception for our workaround for version 3.5+ !

You probably heard of the wmode bug, about broken text input when you use wmode="transparent" or wmode="opaque". Terrible bug! It's been around for years and it's a bloody shame that it hasn't been resolved yet. Numerous posts can be found about this bug and many people have tried to find a suitable workaround. I am no exception. My mission was to make textinputs work acceptably on a full Flex website with wmode capabilities, because we had to use an overlaying iframe (like this for example).

Let's illustrate the problem first. Directly below, you have a wmode="opaque" embedded SWF with 2 textinputs. Now, open a Firefox browser and simply try to type an "@" in the first textinput. If you're on a Belgian AZERTY keyboard like me, I bet you see an "é" and no "@". Pretty hard to type in an e-mailaddress if you can't find the "@", don't you think? And unfortunately, the @ isn't the only problem...

The second textinput does things already a little bit better, thanks to a little (but nasty) hack. I simply re-map bad character input with what it should be by extending the TextInput class. A fully effective remapping is impossible because on different keyboard layouts and on different platforms (mac, pc) I clearly witnessed that there are inconsistencies. This means that 1 key-for-key remapping isn't enough: you'd need one for every type of keyboard (oh, and there are many!). Sadly, I couldn't figure out how to detect a user's keyboard layout. As soon as I discovered that, I gave up... Anyway, here's the source code of my attempt to hack some sense into the TextInput control (see WmodeTextInput class). And by the way, there's the same issue for all other types of text input controls in Flex and Flash, so...

The only 100% effective workaround would be to capture keyboard input with JavaScript and forward that to the SWF. Check out JSTextReader. Unfortunately, this solution isn't working on that many browsers...

P.S. don't hesitate to vote for this bug on http://bugs.adobe.com/jira/browse/FP-479 (and for the other wmode-related bug reports too :-p).

This entry was posted in hacks, workarounds. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

5 Comments

  1. Posted November 25, 2008 at 11:11 am | Permalink

    It took me an half day to find this bug! Means for my client £300. Thanks u Adobe! The only solution I found for the moment is to use a virtual keyboard on my Flex app. Fortunately, my client loves it!

  2. Posted December 1, 2008 at 12:07 am | Permalink

    Please note that this bug appears to be a Mozilla bug and not a problem with the Flash plugin itself. Adobe is cheering from the sideline to encourage Mozilla developers to fix it.

  3. Posted December 9, 2008 at 12:51 pm | Permalink

    Hi Hans,

    Thanks for the great work.
    I have used your mapping in my workaround. Adding now French keyboard support.
    Feel free to create new keyboards support if you want.
    http://nicolas.cynober.fr/blog/116,flex-workaround-for-wmode-bug.html

    Best,
    Nicolas

  4. Posted June 4, 2009 at 1:37 pm | Permalink

    hi,
    the problem seems to have been addressed in Firefox 3.5
    not completely though : the first special character I type is still wrong, but the others are matched ok.
    damn.

  5. Posted August 5, 2009 at 5:30 pm | Permalink

    Thanks for sharing. The slogan on the one waffle is killing me.

One Trackback

  1. By Flex: Workaround for wmode bug on December 9, 2008 at 12:25 pm

    [...] to Hans Van de Velde, for the Beligan Keyboard [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*