Missing feature in TabbedButtonBar

Hi there!

I need a tabbed button bar in my application. The one that comes with JUCE is great - except for one tiny but crucial detail that makes it unusable for my specific needs:

The button bar never sends any notifications when a button was clicked unless the corresponding tab index isn’t the same as the current one.

The logic I need in my application is to make a component visible when its associated tab button is pressed, and hide it, when the same tab button is pressed again.

This would be very easy to achieve if either TabbedButtonBar::setCurrentTabIndex() was virtual, or if there was a way to intercept all mouse/key events via a listener.

… or am I missing something? This is only my second day with JUCE, so I might be on the wrong path.

This is the method that currently breaks my application logic:

void TabbedButtonBar::setCurrentTabIndex( int newIndex, const bool sendChangeMessage_ )
{
   if( currentTabIndex != newIndex ) {
      if( ! isPositiveAndBelow( newIndex, tabs.size() ) ) {
         newIndex = -1;
      }

      currentTabIndex = newIndex;

      for( int i = 0; i < tabs.size(); ++i ) {
         TabBarButton* tb = tabs.getUnchecked( i )->button;
         tb->setToggleState( i == newIndex, dontSendNotification );
      }

      resized();

      if( sendChangeMessage_ ) {
         sendChangeMessage();
      }

      currentTabChanged( newIndex, getCurrentTabName() );
   }
}

Oh, and sorry, this was reformatted to my coding style when I copied it.

Thanks,
Sto

BTW, this is the workaround I’m using in my changeListenerCallback() at the moment:

setCurrentTabIndex( -1, false );

The problem with this workaround is though that the tab no longer reflects the current selection.