# DragAndDropContainer::performExternalDragDropOfFiles usage

**URL:** <https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036>\
**Category:** General JUCE discussion\
**Created:** [June 22, 2014, 11:51am UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036 "2014-06-22T11:51:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mibix](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mibix](https://forum.juce.com/u/mibix)\
**Post date:** [June 22, 2014, 11:51am UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/1 "2014-06-22T11:51:13Z")

</div>

Hello. I'm having a bit of trouble implementing an external drag and drop. I've called the function in&nbsp;MouseDrag(), but it's not working as expected. The little hand symbol comes up, and the following call produces true for the first pixel of drag movement, then false for the rest. Am I going about it all wrong, or is it an issue with me using Linux (I don't have a Windows machine to test on at the minute)? My Component inherits&nbsp;DragAndDropContainer.

&nbsp;

Cheers

&nbsp;

```
void Draggy::mouseDrag (const MouseEvent &event)
{
    
    StringArray sArray;
    sArray.add("~/Desktop/HMA.txt");
    
    bool res = DragAndDropContainer::performExternalDragDropOfFiles(sArray, false);
    
    if (res == true)
    {
        DBG("TRURUR");
    }
    else
    {
        DBG("FALSE");
    }
    
    
}
```

---

<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:** [June 22, 2014, 6:27pm UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/2 "2014-06-22T18:27:29Z")

</div>

You should only call it once, not for every mouse-move. (I think this is explained in the comments for that method)

---

<div class="post-metadata">

**Author:** ![mibix](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mibix](https://forum.juce.com/u/mibix)\
**Post date:** [June 22, 2014, 8:12pm UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/3 "2014-06-22T20:12:59Z")

</div>

Sorry Jules, couldn't see it anywhere in the comments or docs.

I really don't understand the drag and drop at all...

I've changed it from mouseDrag to mouseDown so it only calls once.&nbsp;  
shouldDropFilesWhenDraggedExternally() is being called when I drag out of the JUCE window, but nothing is actually dragged - no icon change etc. I've tried passing the file I want to drag and drop in multiple different places, but non seem to work.

```
void Draggy::mouseDown (const MouseEvent &event)
{
    StringArray sArray;
    sArray.add("~/Desktop/HMA.txt");
    
    startDragging ("THE FILE", this);
    
    DBG("Stared Dragging");
    
    bool res = DragAndDropContainer::performExternalDragDropOfFiles(sArray, true);
    
}

bool Draggy::shouldDropFilesWhenDraggedExternally    
    (    
        const DragAndDropTarget::SourceDetails & sourceDetails,
        StringArray &files,
        bool &canMoveFiles 
    )
{        
    
    if (files.size() == 0)
    {
        DBG("No files passed");
    }
    else
    {
        for (int i=0; i<files.size(); i++)
        {
            DBG(files[i]);
        }
    }
    files.add("~/Desktop/HMA.txt");
    DBG("Passed Outside");
        
    
    return true;        
                
}
```

---

<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:** [June 22, 2014, 9:43pm UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/4 "2014-06-22T21:43:39Z")

</div>

Ah, well maybe it's a linux thing - I've not really tested it in earnest on there. TBH I never call it directly, I generally use the flag in&nbsp;DragAndDropContainer::startDragging that automatically does a drag to external windows. Have you tried the drag + drop page of the juce demo in your OS?&nbsp;

---

<div class="post-metadata">

**Author:** ![mibix](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mibix](https://forum.juce.com/u/mibix)\
**Post date:** [June 24, 2014, 3:25pm UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/5 "2014-06-24T15:25:31Z")

</div>

Cheers Jules. Yeah I've tried the drag and drop in the demo, it doesn't do an external drop, and I've tried every possibility in my own code. It's probably a linux thing - I'm using Lubuntu, with loads of random packages. Something is probably conflicting. I'll try the same thing on Windows as soon as I get my Windows machine back up and running.

&nbsp;

Cheers

---

<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:** [June 26, 2014, 11:37am UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/6 "2014-06-26T11:37:58Z")

</div>

Yeah, this could be something that isn't yet implemented on linux, I can't remember offhand.. Will try to take a look when I get a moment.

---

<div class="post-metadata">

**Author:** ![equinox](https://avatars.discourse-cdn.com/v4/letter/e/47e85d/32.png) [@equinox](https://forum.juce.com/u/equinox)\
**Post date:** [December 13, 2023, 4:34pm UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/7 "2023-12-13T16:34:34Z")

</div>

Hi,  
nearly 10 years later… I am able to drag drop from app → desktop on my mac, but not on linux. Is this implemented on linux? If not are there any plans to do so?

Best,

equinox

---

<div class="post-metadata">

**Author:** ![equinox](https://avatars.discourse-cdn.com/v4/letter/e/47e85d/32.png) [@equinox](https://forum.juce.com/u/equinox)\
**Post date:** [December 14, 2023, 10:21am UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/8 "2023-12-14T10:21:59Z")

</div>

Ah sorry, I was using wayland and not X11. Now after becoming aware of it and changing my ubuntu to X11 things are working again…  
Problem is also mentioned here: [Drag'n drop on wayland](https://forum.juce.com/t/dragn-drop-on-wayland/50105) (but the other way around, so from e.g. nautilus → juce-app)  
Also a good time for me to give a vote for [Wayland support](https://forum.juce.com/t/wayland-support/12591)😄

---

<div class="post-metadata">

**Author:** ![omni](https://avatars.discourse-cdn.com/v4/letter/o/779978/32.png) [@omni](https://forum.juce.com/u/omni)\
**Post date:** [February 20, 2024, 1:24pm UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/9 "2024-02-20T13:24:22Z")

</div>

I’m having a hell of a time getting external drag and drop to work on a Mac. I’m just wondering - the code you posted above - is this what you got working? I’ve tried every variation I can come up with and no matter what, the performExternalDragDropOfFiles function immediately returns false as soon as it’s called. Thank you in advance if you have any pointers!

---

<div class="post-metadata">

**Author:** ![omni](https://avatars.discourse-cdn.com/v4/letter/o/779978/32.png) [@omni](https://forum.juce.com/u/omni)\
**Post date:** [February 20, 2024, 3:58pm UTC](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-usage/13036/10 "2024-02-20T15:58:12Z")

</div>

Welp… I feel like I didn’t change anything with my code and now it’s working. I’ll take the win haha.
