ChangeListener listening to a broadcast from the child of a child component

Hey all!

Just wondering if there is a simple way to pass a listener up 2 parent components. For context I have 3 classes: pluginEditor, control Panel, and singleControlRow.

The ControlPanel is instantiated in the PluginEditor and the SingleControlRow class is instantiated in the ControlPanel class. I was wondering if there was a way for a ChangeListener on the PluginEditor would be able to Listen for Broadcast messages from the SingleControlRow class.

I have implement this event response before when the parent listener is the parent directly above, but cannot think of a good way to do this when the ChangeListener is the parent of a parent component.

Hopefully I have explained this clear enough.

Any help would be so appreciated, I have been racking my brain on this one and have come up with nothing.


You can certainly do that by implementing your own get/set functions and just pass whatever state you need.

However, you might want to consider doing it in a different way. Instead of passing the Component state ‘up’. Hold a state object in the top Component, and pass it ‘down’ to children.

That would make it easier to attach listeners to the state at any level, and also make your Component structure much more flexible.

Hey Eyalamir,

Thanks so much for the Advise. Passing down a listenable state to the child as opposed to passing up from the child does make a lot more sense! I will give a go implementing that and see how it goes.

Thanks again!