PDA

View Full Version : keymaps, windows and panels



arturoterron
27 Jan 2010, 10:04 AM
Hello everybody!
I'm trying to assign and re-assign several keys shortcuts to a panel in a dinamic way. I mean:


var teclas = new Array();
var lon = arNiveles.length;
for (var i = 0; i < lon; i++) {
var nivel = arNiveles[i];
teclas[teclas.length] = {
key: nivel['tecla'],
fn: function () {console.log('ok')}
}
}
pImagenesNiveles.keys = teclas;

pImagenesNiveles.on('afterlayout', function() {this.focus();});
pImagenesNiveles.doLayout();


If pImagenesNiveles is a panel, it doesn't work at all, but if pImagenesNiveles is a window, it works. The problem is that I'd need (but i shouldn't) to totally destroy the window if i want to reassign diferent keys, because


pImagenesNiveles.keys = null before de reasign doesn't work, and the new reassign doesn't affect to the window. If pImagenesNiveles could be a panel, i have not any problem to destroy it and re-create it for a new key reassignement.

I also have tried with:

var keymap = new Ext.KeyMap(document, []);
keymap.addBinding(document, {
key: 'A',
fn: function () {console.log('A');}
});
for every key, but the problem is similar, because i think is not posible to remove the these key assignements.

So, anybody can tell me how to make it works or any alternative?

Thanks in advance.

arturoterron
28 Jan 2010, 6:23 AM
If you need something more to explain, please tell me.
Well, I forgot to say I'm working with 3.1.
Thanks.