Parent Component Communication

This is probably an easy question but I can’t seem to find a good solution.

I have an AudioProcessorEditor class which contains a tabbedComponent. In this, there are going to be 1-4 components.

The AudioProcessorEditor component will have some methods for communicating with the AudioProcessor plugin ( eg. adding a node or removing a node from a graph ). The children components should be able to access these methods as well.

Whats the ideal solution for something like that? At the moment I’m thinking of just passing a pointer (from the parent component) to the children components and just doing it that way. Doesn’t seem that tidy though.

Thanks

You could use Listeners. i.e. onAudioNodeConnected ()

Sounds perfectly reasonable to me. If something needs access to an object, give it a pointer to it. No harm in that, surely?

Or you could use
TargetClass* Component::findParentComponentOfClass

[quote=“masshacker”]Or you could use
TargetClass* Component::findParentComponentOfClass[/quote]

Which, FTR, only works for the currently active tab.

[quote=“Anima”]The children components should be able to access these methods as well.

Whats the ideal solution for something like that? At the moment I’m thinking of just passing a pointer (from the parent component) to the children components and just doing it that way. Doesn’t seem that tidy though.[/quote]

Nope, it’s not tidy at all which is why I made these two classes:

vf::componentNotifyParent
vf::componentBroadCast

[quote=“masshacker”]Or you could use
TargetClass* Component::findParentComponentOfClass[/quote]

vf::componentNotifyParent is far superior to this function