PDA

View Full Version : Reset KeyMap/(Remove listeners/bindings from KeyMap)



tejas_vern
21 Jan 2011, 7:37 AM
Incase you want reuse keymap, remove handlers for keypress listener added previously, dynamically create keymaps.




Ext.override(Ext.KeyMap, {
removeBinding : function(index,count) {
this.bindings.splice(index,count);

}

});

=========================================

var windowKeymap = new Ext.KeyMap(document,{});

//Reset
function(keyMap){

//Remove all added bindings/handlers but 1st
keyMap.removeBinding(1, keyMap.bindings.length);

//Reload
keyMap.addBinding(
[
{
key : Ext.EventObject.A,
fn : function(){},
stopEvent : true
},
{
key : Ext.EventObject.B,
fn : function(){},
stopEvent : true
}
]);
}