Tabbed component - parent?

hey, just wanted to clear something up…

if i have a component in a tabbedcomponent, what would a call to getParentComponent() return? I know i could try it myself and find out :hihi: but i’ve not got time, and it’s not immediately clear to me from the docs, seeing as you don’t actually add it to a component yourself.

Is it straightforward to get hold of the parent of the tabbedcomponent from within one of the tabbed content components? perhaps a getParentComponent()->getParentComponent() ?

silly question i know

Not a silly question, but you should never assume anything about how many nested components your comp is inside. The internal workings of TabbedComponent might change in future, which would break all your code in a nasty way.

The best thing to do is give your inner component a pointer to your parent component when it’s created, so it doesn’t need to look at its parents.

Or, you could recurse up the parent hierarchy dynamically casting the comps until it finds the one that’s the right type. Or give your parent comp a known name and search upwards for that.

yeah i’ve always been a bit frightened of using that for that very reason.

plonking a pointer to the component is what i’ve been doing - that means giving it to the tabbedcomponent and then having that give it to the contained tab panel component also… a part of me thought that may be a bit of a clunkfest but i guess it’s not a problem at all