PDA

View Full Version : BorderLayout panel.onActivate



willgillen
11 Jan 2007, 1:21 PM
I'm trying to figure out how to subscribe to the "active" event of a panel I added to a BorderLayout. How do I do this? I've looked through the documentation, but can't seem to find an example that works. Anyone know how to do this?

tryanDLS
11 Jan 2007, 1:37 PM
It's 'activate', not 'active'. The following should work


mypanel.on('activate', myFn, this, true);

willgillen
11 Jan 2007, 1:41 PM
Actually, I think I may have found how to subscribe to the event with the ".on()" method. (nice).

Now, how can I find the "tab" that is associated witha specific panel (without having to go all the way to the region).

Right now, I'm having to do something like this:
layout.getRegion('center').tabs.getTab(0)

See how I'm having to specify a specific tab. but, in this instance, I already have subscribed to the panel "onActivate" event, so I know the panel, but I want to do something to the tab here. Any method within ContentPanel to find the associated tab?

Thanks!

tryanDLS
11 Jan 2007, 1:50 PM
Unless you kept a ref to the tab when you created it, you have to navigate the via getRegion. However if you mean in your method called by activate, you should have a ref to it passed by the by event firing.

Also the 'tabs' property you used above is meant to be private - if you need to get the collection, use getTabs().

willgillen
11 Jan 2007, 1:57 PM
Well, I have a ref to the ContentPanel when it was created:
I'm using the BorderLayout, and adding content panels to the region.

However, I specifically want to reference the "TAB" that is associated with the ContentPanel. When you add a ContentPanel to a region, the BorderLayout automatically creates the tabpanel/tabs for each ContentPanel added. But in this instance, I need to change the style of a specific TAB along the top when the associated ContentPanel is activated.

I will change my code to use "getTabs()" instead of the .tabs. reference. (thanks!)

-- Will G.