# Drag and Drop function

**URL:** <https://forum.juce.com/t/drag-and-drop-function/195>\
**Category:** General JUCE discussion\
**Created:** [March 19, 2005, 7:18pm UTC](https://forum.juce.com/t/drag-and-drop-function/195 "2005-03-19T19:18:29Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [March 19, 2005, 7:18pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/1 "2005-03-19T19:18:29Z")

</div>

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…

```auto

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 21, 2005, 5:45pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/2 "2005-03-21T17:45:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [March 21, 2005, 8:15pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/3 "2005-03-21T20:15:31Z")

</div>

OK, I will check it, thanks for the answers 😉

(Tracktion 2 Ruuuuuuuules) 8)

---

<div class="post-metadata">

**Author:** ![jtxx000](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jtxx000](https://forum.juce.com/u/jtxx000)\
**Post date:** [March 21, 2005, 11:34pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/4 "2005-03-21T23:34:28Z")

</div>

its not out yet is it???

or are you a beta tester :twisted: 😛

---

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [March 22, 2005, 10:02am UTC](https://forum.juce.com/t/drag-and-drop-function/195/5 "2005-03-22T10:02:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [March 24, 2005, 1:38pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/6 "2005-03-24T13:38:42Z")

</div>

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)
  {
        sa.add(fileHard->getFullPathName());
                        
        if (PlatformUtilities::canDropFilesAtMousePosition())
              PlatformUtilities::dropFilesAtMousePosition(sa);
  }
  dragCours = false;

```

}[/code]

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 ?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 24, 2005, 4:24pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/7 "2005-03-24T16:24:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 24, 2005, 4:31pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/8 "2005-03-24T16:31:05Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [March 24, 2005, 6:48pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/9 "2005-03-24T18:48:48Z")

</div>

Thanks, I will try 😉

---

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [March 26, 2005, 6:32pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/10 "2005-03-26T18:32:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jtxx000](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jtxx000](https://forum.juce.com/u/jtxx000)\
**Post date:** [March 27, 2005, 1:38am UTC](https://forum.juce.com/t/drag-and-drop-function/195/11 "2005-03-27T01:38:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 28, 2005, 11:05am UTC](https://forum.juce.com/t/drag-and-drop-function/195/12 "2005-03-28T11:05:37Z")

</div>

> [@](#):
>
> I have modified the line, recompiled the Juce library and the problem is still alive… I precise I’m working with Win98

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…

---

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [March 28, 2005, 4:44pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/13 "2005-03-28T16:44:40Z")

</div>

Thanks 😉

---

<div class="post-metadata">

**Author:** ![jtxx000](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jtxx000](https://forum.juce.com/u/jtxx000)\
**Post date:** [March 28, 2005, 11:29pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/14 "2005-03-28T23:29:19Z")

</div>

[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… 😛

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 30, 2005, 3:02pm UTC](https://forum.juce.com/t/drag-and-drop-function/195/15 "2005-03-30T15:02:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jtxx000](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jtxx000](https://forum.juce.com/u/jtxx000)\
**Post date:** [April 5, 2005, 12:12am UTC](https://forum.juce.com/t/drag-and-drop-function/195/16 "2005-04-05T00:12:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 9:57am UTC](https://forum.juce.com/t/drag-and-drop-function/195/17 "2017-05-12T09:57:10Z")

</div>


