Drop Target that passes mouse events

Hi, I was wondering if anyone had any pointers for achieving a component that acts as a DragAndDropTarget and a FileDragAndDropTarget but passes all other mouse events through to components beneath.

I have a few classes (various waveform displays etc.) that used the same repeated code to accept dropped audio files. It seemed more elegant to break this code out into its own class, the idea being that I could attach it to a component (using ComponentListener) and it would hover over the target allowing it to behave as normal but catching drops, indicating graphically if it is interested in them.

I thought I could do this with setsInterceptsMouseClicks (false, false) but now realise that the mouse events are used to determine whether the fileDragEnter etc. methods are called. Is this behaviour possible in some way?

Cheers, Dave.

Not easy… A component either catches mouse events or it doesn’t… If I changed the logic in the file-drop code so that it ignored the hitTest region when looking for a target to drop onto, then it’d break code for anyone who’s used a non-rectangular component and who does want the hitTest region to be used when dropping things.

I managed to bodge this by listening to mouse events from the component below and overriding the hit test. Not the most elegant solution but works quite nicely.

I managed to fake the desired behaviour by overriding hittest with the following code:

bool MyFileDragAndDropTarget::hitTest (int x, int y) { if ( isMouseButtonDownAnywhere() ) return false; else return true; };

I assume mouseMove are still being send, but I’m not currently interested by that. The Component ignores mouse downs and accepts drags, exactly the way I wanted it. why ? Because I overly the juce DropTarget over my own interface components.

I would vote though for a solution like:

setInterceptsMouseClicks( false, false ); setReceivesDragAndDropTargetEvents( true );