Any way to be informed of any mouseDown within a single DocumentWindow? [SOLVED]

Is there a way to be informed of any mouseDown that occurs within a single DocumentWindow holding multiple child components, without attaching mouseListeners to all of the children?

Once you add children that accept mouse clicks, those events are not passed to the parent component, so you need to add a mouseListener to the child if you still want them.

With a hundred child components, this would become unwieldy, unless I am missing something very basic.

Something like Desktop::setGlobalMouseListener(), except restricted to a single Window or Component?

Doh! I WAS missing something very basic: just add a Mouselistener to the content component, but specify the arg wantsEventsForAllNestedChildComponents as true. Simple.

You can also add a global mouse listener to the Desktop instance (JUCE: Desktop Class Reference)

1 Like

Thanks - I tried that first - the problem is, you get events for every component in any window, and I just wanted to get them for the one DocumentWindow that my mainComponent is inside, and not for some other peripheral windows I have. But it’s a good one to remember.

1 Like