PDA

View Full Version : [FIXED-1488] KeyMap stopEvent to prevent hot keys in IE



Daniil
6 Jan 2011, 8:01 AM
Hi ExtJS team!

What about to support stopping of event when KeyMap deals with some hot keys in IE such as F5, Ctrl+O, Ctrl+S, F1 (maybe more)?

It works fine in FF, Chrome but not IE.

I understand it's rather IE issue but in according to docs:


stopEvent Boolean True to stop the event from bubbling and prevent the default browser action if the key was handled by the KeyMap (defaults to false)

So, many ExtJS users expects that KeyMap will prevent default behavior of hot keys if they set stopEvent to true.

For now, I use something like this to prevent default IE hot keys behavior:

document.onkeydown = processKey;

var processKey = function(e) {
if (Ext.isIE) {
e = event;
}

if (e.ctrlKey && e.keyCode == 79) {
Ext.Msg.alert("Ctrl+O", "Hello from Ctrl+O");
if (!Ext.isIE) {
e.preventDefault();
return;
}
e.keyCode = 0;
return false;
}

if (e.keyCode == Ext.EventObject.F5) {
Ext.Msg.alert("F5", "Hello from F5");
if (!Ext.isIE) {
e.preventDefault();
return;
}
e.keyCode = 0;
return false;
}
}

Condor
7 Jan 2011, 1:12 AM
Maybe:

Ext.override(Ext.lib.Event, {
preventDefault : function(ev) {
ev = ev.browserEvent || ev;
if (ev.preventDefault) {
ev.preventDefault();
} else {
if (ev.keyCode) {
ev.keyCode = 0;
}
ev.returnValue = false;
}
}
});

ps. You can't stop the F1 key this way. For that you need to stop the 'help' event.

Daniil
10 Jan 2011, 11:01 AM
Hi Condor,

Thanks for the suggestion.


ps. You can't stop the F1 key this way. For that you need to stop the 'help' event.

Yes, you are totally right. I use document.onhelp to override F1 behavior in IE.

Also, thanks ExtJS team for opening a bug ticket. This will make our application more clear and readable.

meroy
10 Jan 2011, 12:19 PM
This has been added into the Ext 3.3.x branch in SVN.