Mouse Events though the Components


#1

Hi !

I came accross this situation where i have [FileDragAndDropTarget] component and another UI component on top of it ... 

What i want to achieve is to be able to click on that TOP compoment but also be able to drop files onto [FileDragAndDropTarget] component under it .

I thought that i can achieve it with the [setInterceptsMouseClicks] method (searched the forum already), but no luck ... 

Is there something i can do ?


#2

I think, if you add the back component as MouseListener to the top most, you get the mouse events in both components.

see https://www.juce.com/doc/classComponent#ae45db6bb7d7826eb7e936c21fec105ce

HTH, daniel


#3

thanks Daniel !

yeah it seems to pass the MouseEvents through, but i must be doing something silly ...

So i made the [FileDragAndDropTarget] as a TOP most component, and registered all the BOTTOM components as a MouseListener to it.

MouseEvents are passed through, i can proove it by monitoring Component's MouseDown/MouseDrag methods ... however BOTTOM components do not react to this, even if their MouseDown/MouseDrag methods are called. Why its stopping them from beeing repainted/updated ? i must be missunderstanding something obvious here .


#4

if you can change your gui structure so you can avoid overlaying components, it will probably make things easier...

However, if the component is occluded by the component in front, it needs to know, that it is still visible. You can give the system a hint via setOpaque to false: https://www.juce.com/doc/classComponent#a7320d543cba40183c894474ab78798ea but not being opaque is the default, so probably this won't help, but worth to check...

Good luck...


#5

I had partial luck :D thanks anyway ...

Thats the whole fun with overlaying components as a desired composition ... its a special case anyway, but its required to work.

 

I do not have long experience in that matter so i must be doing silly things that makes me wonder about the causes.

In my scenario, BOTTOM components where containers for the Sliders. When i tried to add those containers as a [MouseListener] to the TOP most component that was my [DragAndDropTarget] i could receive [Mouse Events] but those events werent passed to its child components (Sliders) . I had to register those [Sliders] as a [MouseListeners] to my [DragAndDropTarget] component directly which made them respond to [Mouse Events]. 

Can i easily avoid that situation, and let the containers pass [Mouse Events] to its [Sliders] without reqistering them individually  ?


#6

Sorry, that's how I would have tried it also, put the big one in front to catch all and send it to the hierarchy in the back...

Maybe somebody else has an idea...

Good luck


#7

yeah , thanks Daniel for your brain time. And its good to confirm things with others ...

 

Anyone else see any chance there ?