Parent Component Communication


#1

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


#2

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


#3

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


#4

Or you could use
TargetClass* Component::findParentComponentOfClass


#5

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

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


#6

[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


#7

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

vf::componentNotifyParent is far superior to this function