Another architecture question


#1

Another noob question. Say I have the following object structure:

                        Application
       Other stuff                  Window
   objects...                               widgets...

That is to say, a tree that branches out from the application object into two smaller trees.

Now I want, events and other stuff that happens in a widget to cause things to happen in the “other stuff” tree. Normally what I’d do is to instantiate the other tree first and then pass an appropriate pointer along with the constructors for the widgets, or something along those lines.

But, as the trees are growing pretty large passing that pointer around is getting messy. So is there a more efficient way of hooking in listeners etc.
I’m considering using a singleton as a sort of registry so that all objects can acquire what they need from there.

Or…It just occurred to me, does JUCE have anything that lets you grab a widget by name? That would probably do the trick.


#2

can’t you just use the application command manager system?


#3

Ha! I didn’t know that was in there.
Not sure that it fits the bill, though it seems easy enough to use. I’ll look into it.


#4

Ah, never mind. I solved it by restructuring the entire thing. (I try to code by the principle that if I can’t see an intuitive solution, I assume the premises of the problem are wrong.)

Funny how I never noticed the application command thing, though. Cheers.


#5