PDA

View Full Version : GXT: Switching between tabs in TabPanel



angelique
11 Aug 2010, 2:15 AM
I am able to switch the tabs in the TabPanel while using CTL+Arrow keys. The problem is, I am able to do this only if the focus is on the panel itself. I would like to switch between tabs even if the focus is on the components inside the tab. Is this possible?
Here is the code I have created to switch between tabs:


addListener(Events.KeyPress, new KeyNav<ComponentEvent>(this) {
public void onKeyPress(ComponentEvent ce) {
indexMax = centerPanel.getItemCount();
if (ce.isControlKey() && ce.getKeyCode() == KeyCodes.KEY_RIGHT){
if(index == indexMax - 1)
index = 0;
else
index++;
centerPanel.setSelection(centerPanel.getItem(index));
}

if (ce.isControlKey() && ce.getKeyCode() == KeyCodes.KEY_LEFT){
if(index > 0)
index--;
else
index = indexMax-1;
centerPanel.setSelection(centerPanel.getItem(index));
}
}
});

Thank you. :)