Mouse Entering component while mouse drag started in other component

I want to be able to start dragging the mouse inside one component, then hover over another component, and depending on which other component i hover over, update the ui accordingly.

The problem I have: mouseEnter/Exit callbacks are explicitely not being sent while the mouseDrag callback is active from another component.

Is there maybe a workaround?
The only thing that comes to mind for me right now is hardcoding the distance in px, but that just feels stupid.

in mouseDrag you could check if the screenPosition of the mouse event overlaps the screenBounds of any other component and if yes perform a certain operation on that component like repaint etc

Yeah this works.
However I now decided to just use isMouseButtonDown(true) in the top parent of this whole area and then check via juce::desktop::getMousePosition() if the current position overlaps ractangles of the same size/position of one of the components in question.

If the component you are hovering inherits DragAndDropTarget (that is it can potentially receive drags), you get callbacks like itemDragEnter and itemDragExit.
Those are exactly for the purpose so a possible target can show feedback, e.g. highlight or what it would do if you drop there.

1 Like