PDA

View Full Version : My Ext.KeyMap stopEvent not actually stopping browser event



MD
19 Aug 2007, 10:52 AM
I just noticed that one of my Ext.KeyMap's that spawns a dialog is intermittently NOT stopping the default browser event. I have it mapped to Ctrl+U, which in Firefox will normally bring up the view Page Source window. It works, then I do a reload of my page later, doesn't work... reload again, works again -- It seems fairly random, which makes it all the more frustrating/confusing. ;) Any ideas? :-/

This is a very pared-down example of how I have it set up, but shows how I have the KeyMap set and stopEvent set. Even went so far as to make the changes suggested here (http://extjs.com/forum/showthread.php?t=6122&highlight=keymap+stopevent) in order to have it accept the stopEvent as a config var, and added an e.stopEvent() in the function:



var pub = {};
pub.prv = function(){

var myDialogKeyMap;

init : function(){
myDialogKeyMap = new Ext.KeyMap(Ext.get(document), {
key: "u",
ctrl: true,
stopEvent: true,
fn: function(key, e){
console.log(key);
console.log(e);
console.log('Pressed Ctrl+U');
pub.priv.myDialogKeyMapFnc('blah');
e.stopEvent();
}
});
myDialogKeyMap.stopEvent = true;
},

myDialogKeyMapFnc : function(arg){
console.log(arg);
}
}();

MD
3 Sep 2007, 6:24 AM
Bueller?

Animal
3 Sep 2007, 6:30 AM
Sometimes you can't override what the browser wants to do.

Animal
3 Sep 2007, 6:32 AM
However, just copying



myDialogKeyMap = new Ext.KeyMap(Ext.get(document), {
key: "u",
ctrl: true,
stopEvent: true,
fn: function(key, e){
console.log(key);
console.log(e);
console.log('Pressed Ctrl+U');
e.stopEvent();
}
});
myDialogKeyMap.stopEvent = true;


into the Firebug console and running it, consistently handles and cancels the Control+U keystroke.