PDA

View Full Version : How to add handler to TabPanel's buttons ?



openthesky7
11 Jan 2011, 12:11 PM
I wonder how to add handler to TabPanel's button.. I have card layout panels grouped in TabPanel, and I want to reset activeItem to 0, when I click the tabpanel's button.

Any ideas?

AndreaCammarata
11 Jan 2011, 12:39 PM
Hi openthesky7.
You can add a listener to your TabPanel to be notify before the active card change in this way:



...
listeners: {
beforecardswitch: function(cnt, newCard, oldCard, index, animated) {
//If the event is fired this means that you tap on a TabPanel button
}
}
...

Hope this helps.

openthesky7
11 Jan 2011, 12:49 PM
Almost.. Because this doesn't work when you press button on active card..

I'm trying somting like this.. "rootPanel.getTabBar().getComponent(0)..... " and add handler to that button.

For example "rootPanel.getTabBar().getComponent(0).setVisible(false);" could hide the button... So maybe I could add the handler.

openthesky7
11 Jan 2011, 12:54 PM
Yeah! :)

I've got it:


rootPanel.getTabBar().getComponent(0).addListener('tap', myHandler);

AndreaCammarata
11 Jan 2011, 1:03 PM
Exactly ;)