My VST creates a series of generated audio files, writes them to disk somewhere. But I’d like users to be able to drag these audio files from the VST → back into the DAW.
I decided to make my PluginEditor.cpp inherit from DragAndDropContainer, since the docs say:
“For a component to be able to make or receive drag-and-drop events, one of its parent components must derive from this class. It’s probably best for the top-level component to implement it.”
Here’s where I get a little more confused:
" Then to start a drag operation, any sub-component can just call the startDragging() method, and this object will take over, tracking the mouse and sending appropriate callbacks to any child components derived from DragAndDropTarget which the mouse moves over."
So I decided to structure my application like this:
It feels like the way I’d have to do this is on each mouseDown in a GeneratedAudioComponent, I’d either have to have a saved reference to the parent class (PluginEditor), or find it with ( findParentDragContainerFor) and then call the editor.startDragging() function
Is there any sort of built in debouncer or other way to filter these events in JUCE?
It seems like it’s able to drag the file without issue, but I worry that this function is getting called 20 times per actual mouse drag. Could just be that I don’t understand the JUCE eventing model yet though!
This is expected. If your mouse updates at a rate of 100hz, you should have that function called 100 times. The dragging event is a continuous event like “mouse move”, but unlike "mouse down/mouse up/mouse enter/… .
If this helps to clarify things, you could do your own mouse drag event like this →