[dojo-contributors] Event handling proposal

Kris Zyp kzyp at dojotoolkit.org
Thu Mar 17 12:06:41 EDT 2011


On 3/17/2011 9:32 AM, Bill Keese wrote:
> Oh nevermind, it loads, it's just that firebug stops in your feature
> test code on the exception:
>
> try{
>    testKeyEvent = document.createEvent("KeyboardEvent")  
>     testKeyEvent.initKeyboardEvent("keypress", true, true, null,
> false, false, false, false, 9, 3);
> }catch(e){}
>
> Would be nicer for firebug users and perhaps faster if that code
> checked if testKeyEvent.initKeyboardEvent was defined before trying to
> call it and getting an exception.
Yeah, the feature test is just wrong for FF3.6, because it 3.6 has
initKeyEvent instead of initKeyboardEvent (which was added in FF4). It
should be something like this, I guess:
(testKeyEvent.initKeyboardEvent ||
testKeyEvent.initKeyEvent).call(testKeyEvent, true, true, null, false,
false, false, false, 9, 3);

Although this whole feature test feels pretty fragile, I don't know that
it is really properly testing what we are looking for. I don't know that
it is really any better than user agent sniffing in this case. And I am
even more lost on how to branch for Opera handling of keypress. If the
feature detect experts have any advice on how this should be done, I
would love to know.
Kris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20110317/8a2332fc/attachment.htm 


More information about the dojo-contributors mailing list