Adding a FileDragAndDropTarget on top of other components

I’m trying to implement my audio plugin so that it accepts files to be dropped on it anywhere in the window, regardless of other widgets.

I tried to use FileDragAndDropTarget, and while I can get it to work on its own, problems arise when I try to add other widgets underneath it.

I created a class that inherits from both Component and FileDragAndDropTarget. The paint method will draw a translucent fill over the whole window (that’s why I want this component on top), and I also call setBounds() on it from the AudioProcessorEditor that contains it.

(Later I will replace this target with a couple of smaller ones that cover different sections of the GUI)

I would like it to listen to all the drag events, i e isInterestedInFileDrag, fileDragEnter, fileDragExit and filesDropped.
But I want it to ignore all other mouse events, so that they are passed through to the other components underneath.
I tried setting InterceptsMouseClicks to false, but then it would start ignoring the file dragging events too, and if it’s set to true, then the Components underneath stop responding, of course.

Is there any neat and simple way to make this work?

Perhaps you could consider an approach where your top-level component is itself a juce::FileDragAndDropTarget, and your translucent fill is a separate, standalone component which doesn’t intercept mouse clicks. When your main component receives a file-drop callback, it can call a member function on the overlay component, telling it to update somehow (e.g. fade the translucent fill in/out).

Yes, that did the trick! This is definitely an acceptable solution. When I split into several drop zones later on they will still represent different GUI sections anyway, so they can be the parent Component for each section.

Thanks!