My background is in MFC so forgive my ignorance when it comes to JUCE. I’ve been able to create a great working prototype already picking apart the examples but there is a problem I just cant wrap my head around.
I’ve written a component that I use as a container for other components, it automatically sizes the other components that I include. However one of those subcomponents includes a button that can turn off and on the other components from the container. Since this component is an object in the container it doesn’t have access to the functions in the container in its own class.
I thought ApplicationCommandTarget was the answer to my problems but I just couldn’t figure out invoking them from within. Any help?
In my opinion these are superior to the use of application commands, because setting up application commands requires a lot of framework to be added, whereas these classes are extremely lightweight and modular.
Also note that VFLib includes this class, which acts as a resizable container with quite a bit of flexibility:
This sounds to me like you’re just struggling with basic programming concepts, rather than looking for some kind of high-level message-passing solution…? If you have a component that needs to call another one, just give it a pointer to that object!
This seems likely what I need since I’m trying to call functions that are sometimes in parents of parents. I’m also curious of the innate JUCE framework way of accomplishing this same task if you could explain that.
So then I should be making circular references in every instantiated class that my object contains? I’ve never come across something like this before maybe I am missing something basic here. Are you saying the below code would be the correct way to set up event handling for Class B to have access to the commands from Class A?
[code]//Class_A.h #include “Class_B.h”
class Class_A : public Component
class_b = new Class_B( this );
//Class_B.h #include “Class_A.h”
class Class_B : public Component
class_a = a;
JUCE doesn’t have something like that. It makes use of std::bind (and more importantly, bind placeholders) which JUCE doesn’t use at all. And I rather doubt Jules would want to implement placeholders since they are a cumbersome to write.
I think that Jules didn’t quite understand what you were trying to do. My classes were written explicitly for your use-case.
No joke. I added your modules, wrote an interface header and I’m up and running. It functions exactly as I hoped it would regardless of the number of components I’m nested. This is really nice because now I’m able to abstract all my controller logic away from the individual components.
Just wanted to come back and say thank you for your contribution.