# FileTreeComponent drag and drop misunderstanding

**URL:** <https://forum.juce.com/t/filetreecomponent-drag-and-drop-misunderstanding/4517>\
**Category:** General JUCE discussion\
**Created:** [November 15, 2009, 10:56am UTC](https://forum.juce.com/t/filetreecomponent-drag-and-drop-misunderstanding/4517 "2009-11-15T10:56:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eacolin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eacolin/32/345_2.png) [@eacolin](https://forum.juce.com/u/eacolin)\
**Post date:** [November 15, 2009, 10:56am UTC](https://forum.juce.com/t/filetreecomponent-drag-and-drop-misunderstanding/4517/1 "2009-11-15T10:56:11Z")

</div>

Hello, I’m a new Juce user, just getting used to this insanely useful system. I’m having a bit of a misunderstanding as far as how to use a FileTreeComponent’s drag and drop functionality. Basically, I want to have a file tree where when the user drags a file onto a box, it returns the file’s path. I’m having some trouble getting the file tree to act as a drag and drop at all though. I’m trying to use :

void FileTreeComponent::setDragAndDropDescription ( const String & description ) throw ()  
Setting a name for this allows tree items to be dragged.

But basically, it’s just not happening: can’t drag anything. At the moment I’m just trying to get it to say “File!” whenever it’s dropped, but no dice. Maybe I’m misunderstanding the documentation, is there something else I should do? Here’s the code snippet:

[code] File folder (File::getSpecialLocation (File::userHomeDirectory));  
while (folder.getParentDirectory() != folder)  
folder = folder.getParentDirectory();

```
directoryList = new DirectoryContentsList (0, thread);

directoryList->setDirectory (folder, true, true);

thread.startThread (3);

addAndMakeVisible(fileTree = new FileTreeComponent(*directoryList));

fileTree->setDragAndDropDescription ( T("File!") );[/code]

```

Any tips greatly appreciated. Hopefully I can become a helpful part of the forum rather than just a help-seeker once I get a better handle on juce.

-Colin

---

<div class="post-metadata">

**Author:** ![jsolo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jsolo/32/30_2.png) [@jsolo](https://forum.juce.com/u/jsolo)\
**Post date:** [November 15, 2009, 5:41pm UTC](https://forum.juce.com/t/filetreecomponent-drag-and-drop-misunderstanding/4517/2 "2009-11-15T17:41:19Z")

</div>

Hey Colin

Take a look at the DragAndDropContainer class.

> [@](#):
>
> For a component to be able to make or receive drag-and-drop events, one of its parent components must derive from this class. It’s probably best for the top-level component to implement it.

and the DragAndDropTarget

> [@](#):
>
> Components derived from this class can have things dropped onto them by a DragAndDropContainer.

Hope that points you in the right direction.

---

<div class="post-metadata">

**Author:** ![eacolin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eacolin/32/345_2.png) [@eacolin](https://forum.juce.com/u/eacolin)\
**Post date:** [November 15, 2009, 10:59pm UTC](https://forum.juce.com/t/filetreecomponent-drag-and-drop-misunderstanding/4517/3 "2009-11-15T22:59:53Z")

</div>

Aha! I made the parent component a DragAndDropContainer and it works like a charm. Thanks so much!

-Colin

---

<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:50am UTC](https://forum.juce.com/t/filetreecomponent-drag-and-drop-misunderstanding/4517/4 "2017-05-12T09:50:33Z")

</div>


