MouseEvent on parents AND children

Hi Jules and comunity,

I’ve came across a problem which made me have to do a really nasty hack.

I have a hierachy of components

Comp1 is parent of Comp2 which is parent of Comp3.

Comp1 and Comp3 are both interested in MouseEvents.
I spend a couple of hours playing with setInterceptsMouseClicks, before finaly reading the doc ( :smiley: ) …and realizing there’s no clean way do to this !
If comp3 calls setInterceptMouseClicks(false,true), then comp1 gets the events but not comp3 .
If comp2 calls setInterceptMouseClicks(false,true), then comp3 gets the events but not comp1 .
And so on …

The only way I found to do that is to override mouseDown, mouseUp and mouseDrag in comp3 so they do something like :

which is really nasty in terms of design and code (Of course the code above can be improved a lot, but that’s not the point)

Did I miss something or is this really the only way to deal with MouseEvents and component hierarchies ?

Sounds like you need to use Component::addMouseListener().

:oops: Mmmmh …yeah of course :oops: