# performExternalDragDropOfFiles is not synchronous on MAC

**URL:** <https://forum.juce.com/t/performexternaldragdropoffiles-is-not-synchronous-on-mac/28115>\
**Category:** MacOSX and iOS\
**Created:** [June 13, 2018, 1:01pm UTC](https://forum.juce.com/t/performexternaldragdropoffiles-is-not-synchronous-on-mac/28115 "2018-06-13T13:01:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrikwa](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@patrikwa](https://forum.juce.com/u/patrikwa)\
**Post date:** [June 13, 2018, 1:01pm UTC](https://forum.juce.com/t/performexternaldragdropoffiles-is-not-synchronous-on-mac/28115/1 "2018-06-13T13:01:41Z")

</div>

The documentation for this function clearly states that

"This performs a synchronous drag-and-drop of a set of files to some external application.

You can call this function in response to a mouseDrag callback, and it will block, running its own internal message loop and tracking the mouse, while it uses a native operating system drag-and-drop operation to move or copy some files to another application."

And it will return  
“true if the files were successfully dropped somewhere, or false if it was interrupted”

This is not at all how it is behaving on MAC currently, instead it will return immediately after calling this, it will return true if a drag could be started and false otherwise.

Is this a bug or is the documentation wrong? What is intended?  
Are there any plans on fixing this so it works the same as on Windows where it works just like the documentation states?

Currently we do a lot of not-so-pretty hacks to counter this behavior on MAC, it would be nice to not have to do that 🙂

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [June 13, 2018, 1:24pm UTC](https://forum.juce.com/t/performexternaldragdropoffiles-is-not-synchronous-on-mac/28115/2 "2018-06-13T13:24:35Z")

</div>

Feel free to join the currently open conversation in @Rail\_Jon\_Rogut’s thread:

> [@DragAndDropContainer::performExternalDragDropOfFiles() Asynchronous and DragImageComponent issue](https://forum.juce.com/t/draganddropcontainer-performexternaldragdropoffiles-asynchronous-and-dragimagecomponent-issue/28071):
>
> The comments say that DragAndDropContainer::performExternalDragDropOfFiles() is synchronous… but it isn’t. My real issue… (On MacOS) I have a screen repaint issue if you start a drag from a TableListBox and drop it (drag, stop dragging and lift your mouse finger) on the plug-in UI… Say on the TableListBox itself… it won’t delete the DragImageComponent until you move the mouse… and DragAndDropContainer::dragOperationEnded() is triggered only after a mouse move… so I can’t try: void CGrooveCo…

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [July 18, 2018, 4:22pm UTC](https://forum.juce.com/t/performexternaldragdropoffiles-is-not-synchronous-on-mac/28115/3 "2018-07-18T16:22:27Z")

</div>

Thanks for the report @patrikwa. [This commit](https://github.com/WeAreROLI/JUCE/commit/4280b51d091e678d52f18eafd3117e0aa23317b8) has changed the behaviour of `DragAndDropContainer::performExternalDragDropOfFiles()` and `::performExternalDragDropOfText()` so that they are asynchronous operations on all platforms (previously only Windows was synchronous) and the docs have been updated to reflect this. This means that the operation will no longer block the message thread on Windows as it runs on a separate background thread, but you can pass the methods a callback parameter which will be called when the operation has ended.

Hopefully you’ll agree that uniformly doing this asynchronously is a better solution and you should be able to work around any issues that arise using the callback, but feel free to post back if you have any issues.
