# Using custom TabbedButtonBar with TabbedComponent?

**URL:** <https://forum.juce.com/t/using-custom-tabbedbuttonbar-with-tabbedcomponent/24246>\
**Category:** General JUCE discussion\
**Created:** [September 19, 2017, 2:52am UTC](https://forum.juce.com/t/using-custom-tabbedbuttonbar-with-tabbedcomponent/24246 "2017-09-19T02:52:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathonracz](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jonathonracz](https://forum.juce.com/u/jonathonracz)\
**Post date:** [September 19, 2017, 2:52am UTC](https://forum.juce.com/t/using-custom-tabbedbuttonbar-with-tabbedcomponent/24246/1 "2017-09-19T02:52:04Z")

</div>

I’m trying to use a custom `TabbedButtonBar` class with a `TabbedComponent`. It’s easy to implement my own custom tabs via to the virtual `createTabButton`, but I don’t see any equivalent for the button bar itself. The closest thing is the `protected` `ScopedPointer` object `tabs`, but arbitrarily replacing the contents of that pointer seems wrong (and crashes anyway, when I tried it out of curiosity in my derived `TabbedComponent`'s constructor).

FWIW, what I’m implementing are special-case draggable/rearrangeable tabs.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 19, 2017, 7:54am UTC](https://forum.juce.com/t/using-custom-tabbedbuttonbar-with-tabbedcomponent/24246/2 "2017-09-19T07:54:43Z")

</div>

It’s not something I’d thought anyone would want to do, but if you want to suggest a non-hacky change to TabbedComponent that would make it possible to do what you need, I’d be happy to take a look.

---

<div class="post-metadata">

**Author:** ![bgporter](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/bgporter/32/12710_2.png) [@bgporter](https://forum.juce.com/u/bgporter)\
**Post date:** [September 19, 2017, 12:07pm UTC](https://forum.juce.com/t/using-custom-tabbedbuttonbar-with-tabbedcomponent/24246/3 "2017-09-19T12:07:16Z")

</div>

FWIW, this also would have been handy for me recently; the client’s feature request has been deferred for now. (And I guarantee that they’ll be asking for draggable tabs before long…)

First thought was to add a counterpart to this that lets your class return a derived button bar class:  
`virtual TabBarButton * createTabButton (const String &tabName, int tabIndex)`

like

`virtual TabBarButton * createTabbedButtonBar(orientation)`

…until I saw that the button bar is created in the component’s ctor, and the virtual function call wouldn’t work.

Is it unreasonable to make this a template class specialized on the type of the button bar?

---

<div class="post-metadata">

**Author:** ![jonathonracz](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jonathonracz](https://forum.juce.com/u/jonathonracz)\
**Post date:** [September 19, 2017, 4:13pm UTC](https://forum.juce.com/t/using-custom-tabbedbuttonbar-with-tabbedcomponent/24246/4 "2017-09-19T16:13:41Z")

</div>

Thanks for offering to take a look. I’m usually extremely averse to modifying JUCE code directly (i.e. for a pull request) and come up with crazy workarounds with subclasses that carefully modify JUCE object state based on knowledge from the normal implementations instead. If I come up with something I’ll post here.

I think @bgporter is onto the right idea, but a template definitely isn’t the way to go since that isn’t how any other composite components (to my knowledge) are designed. We’d definitely want something like `virtual TabBarButton * createTabbedButtonBar(orientation)`…
