PDA

View Full Version : Kemap problem



goofy
20 Nov 2010, 7:36 AM
Hi

i try many possibilites, this the last one :



{
xtype: 'tabpanel',
id: 'Editsublayout',
activeTab: 0,
resizeTabs:true,
minTabWidth: 100,
tabWidth:'auto',
region: 'center',
disabled: true,
disabledClass: 'tab-disabled',
enableTabScroll: true,
listeners: {
afterrender: function(c){
c.keyMap = new Ext.KeyMap( c.getEl(), {
key: [33, 34],
stopEvent: true,
fn: function(e){
var tabs= Ext.getCmp('Editsublayout');

// note the items.items - no idea why
var items = tabs.items.items;

// grab the active tab
var active_tab = tabs.getActiveTab();

// grab the total number of tabs
var total_tabs = items.length;

// loop the tabs
for(i = 0 ; i < items.length; i++)
{
// find the active tab based on the id property.
if (active_tab.id == items[i].id) {
// do we want to move left?
if (e == 34)
{
// move left
var next = (i - 1)
if (next < 0) {
// we're at -1, set to last tab
next = (total_tabs - 1);
}
}
else
{
// move right
var next = (i + 1);
if (next >= total_tabs)
{
// we've gone 1 too many set to start position.
next = 0;
}
}
// set the tab and return there's no need to carry on
tabs.setActiveTab(items[next].id);
return;
}
}
}
});
console.log(c);
}
}
}


But, when i press the key, i get no firebug error but no log too

the only solution to get this to work is to define the keymap on document object but my tabpanel is in another tabpanel and this work only on time for the first one (in parent tab).

( I have try the keys param or on render listeners too)

If someone have an idea please ?

Screamy
22 Nov 2010, 10:28 AM
Try declaring your key map as an attribute of the tab panel:


{
xtype: 'tabpanel',
id: 'Editsublayout',
activeTab: 0,
resizeTabs:true,
minTabWidth: 100,
tabWidth:'auto',
region: 'center',
disabled: true,
disabledClass: 'tab-disabled',
enableTabScroll: true,
keys: [{
key: [Ext.EventObject.PAGE_UP], handler: somePageUpHandlerMethod
},{
key: [Ext.EventObject.PAGE_DOWN], handler: somePageDownHandlerMethod
}],
.......... etc. ..........