Drag and Drop function

Hello everybody !

Here is my problem : I want to add a Drag and Drop feature in my program to allow the drag and drop of MIDI files into Tracktion… I know it’s possible to do this because I have tried to drag and drop a MID between Tracktion and the Windows’ Explorer window…

How can I do this with Juce ? The function I must use is this one but I don’t know how to configure it…

no, that’s only for internal juce-based dragging, it can’t drag things outside into other apps.

Check out PlatformUtilities::canDropFilesAtMousePosition() and dropFilesAtMousePosition(). You can use these in your mouseDrag() and mouseUp() methods, and set the cursor appropriately.

OK, I will check it, thanks for the answers :wink:

(Tracktion 2 Ruuuuuuuules) 8)

its not out yet is it???

or are you a beta tester :twisted: :stuck_out_tongue:

No, a friend was at the NAMM in France and have seen it :lol:

Oops Jules, I think I have found a bug in Juce… First Check what I have written :

[code]void mouseDrag (const MouseEvent& e)
dragCours = true;

void mouseUp (const MouseEvent& e)
StringArray sa;

  if (dragCours)
        if (PlatformUtilities::canDropFilesAtMousePosition())
  dragCours = false;


As you have understood, that doesn’t work, and if I try for example to drag in the Dev C++ Explorer, it shows me one window for each character in the path, for “C:\Win.mid” it says me :

“Can’t find C”
“Can’t find :”
"Can’t find "
“Can’t find W” etc. etc. etc.

But if i drag and drop from the Windows’ Explorer windows, that works. So maybe a bug in Juce ?

hmm - must be because it’s passing windows a unicode filename… I’ll investigate.

yeah - looks like I messed up. The line in PlatformUtils.cpp that says

pDropFiles->fWide = SystemStats::getOSType() == SystemStats::Win95 || SystemStats::getOSType() == SystemStats::Win98;

should just be:

pDropFiles->fWide = true;

God knows what I was thinking when I wrote that…

Thanks, I will try :wink:

I have modified the line, recompiled the Juce library and the problem is still alive… I precise I’m working with Win98 :cry:

Another question that’s slightly off topic:
Is there any way to have drag and drop between two running instances of the same app?

oh, maybe win98 doesn’t handle the wide char stuff properly. Try setting the value to false and see if that works - I’ll have a proper look at it for the next release…

Thanks :wink:

[quote=“jtxx000”]Another question that’s slightly off topic:
Is there any way to have drag and drop between two running instances of the same app?[/quote]

i guess that’s a no… :stuck_out_tongue:

well you can use the normal drag + drop, like you would between juce and non-juce apps, but not the clever internal drag-and-drop stuff because they don’t live in the same memory-space.

i tried using dropFilesAtMousePosition() but it doesn’t seem to be working for some reason. When i try to drag between two instances of my app canDropoFilesAtMousePosition() returns true but dropFilesAtMousePosition() doesn’t call the filesDropped() method on the other app. if you try to drop a file from my app to windows explorer canDropoFilesAtMousePosition() returns false.

what am i doing wrong?