[RESOLVED] Problems with performExternalDragDropOfFiles

I’m having issues trying to drag an audio file out of my app and into a DAW or a file folder. My code is below. It says that it is succeeding, and sometimes it does, for a DAW.

When I drag to Studio One timeline, sometimes it drops the file properly, and sometimes it just flashes a snapshot of the waveform for an instant, which then disappears and nothing gets dropped.

When I drag to the desktop (on my Mac) or to a folder I created for testing on my desktop, it always shows the “can’t do this” icon (circle with a slash through it), and never lets me drop it anywhere. I can see the temp.wav file get created on my desktop, so I know that the “writeExportedFile()” function succeeded in writing my file.

What am I missing here? (It’s very difficult to find a complete example of doing this. People just say “use performExternalDragDropOfFiles” and the reply is “that worked”. Not exactly useful. lol.)

void PlaybackViewComponent::mouseDrag (const juce::MouseEvent& e)
{
	if (!dragStarted)
	{
		// Export to temp file
		juce::File tmpFolder = juce::File::getSpecialLocation(juce::File::userDesktopDirectory);
		juce::File tmpFile = tmpFolder.getChildFile(juce::String("temp")); // TODO:
		if (writeExportedFile(tmpFile))
		{
			if (mainComp.performExternalDragDropOfFiles({tmpFile.getFullPathName()}, true))
				dragStarted = true;
		}
	}
}

void PlaybackViewComponent::mouseDown (const juce::MouseEvent& e)
{
	if (e.mods.isAltDown())
	{
		dragStarted = false;
	}
}

void PlaybackViewComponent::mouseUp (const juce::MouseEvent&)
{
	dragStarted = false;
}

make sure writeExportedFile calls flush ?

Oh, never mind! The problem is that I used Option+click to initiate the drag, but option+dragging differs from simply dragging, and is the whole reason why I was seeing this behavior. I’ll need a different way to distinguish that I want to drag the file and not just move the cursor in my component’s graph. D’oh! Lol!