# FileBrowserComponent Drag and Drop request/idea

**URL:** <https://forum.juce.com/t/filebrowsercomponent-drag-and-drop-request-idea/4779>\
**Category:** General JUCE discussion\
**Created:** [January 25, 2010, 9:00pm UTC](https://forum.juce.com/t/filebrowsercomponent-drag-and-drop-request-idea/4779 "2010-01-25T21:00:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![comboy](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@comboy](https://forum.juce.com/u/comboy)\
**Post date:** [January 25, 2010, 9:00pm UTC](https://forum.juce.com/t/filebrowsercomponent-drag-and-drop-request-idea/4779/1 "2010-01-25T21:00:35Z")

</div>

hello 🙂  
just spend quite a while figuring out how to make a file browser drag and drop capable.  
a forum search just brought up the idea of using my own TreeViewItemComponent, which doesn’t work without much coding work 😉

in the end i figured out you just have to add one line in the FileBrowserComponent constructor.

```auto
...
FileTreeComponent* const tree = new FileTreeComponent (*fileList);
        tree->setDragAndDropDescription(T("MyName")); //<------ enables drag and drop
...
```

would be great to have access to this either through a constructor parameter or a function call, so i would’nt have to use my own component just for this one line.

cheers,  
comboy

---

<div class="post-metadata">

**Author:** ![peteblues](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@peteblues](https://forum.juce.com/u/peteblues)\
**Post date:** [April 19, 2010, 5:44pm UTC](https://forum.juce.com/t/filebrowsercomponent-drag-and-drop-request-idea/4779/2 "2010-04-19T17:44:13Z")

</div>

this unfortunately works only when you’re using the tree view. Do you have any tricks like this when using the list view? I haven’t been able to figure this one out without much coding work.

---

<div class="post-metadata">

**Author:** ![RiphRaph](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@RiphRaph](https://forum.juce.com/u/RiphRaph)\
**Post date:** [February 18, 2015, 11:38am UTC](https://forum.juce.com/t/filebrowsercomponent-drag-and-drop-request-idea/4779/3 "2015-02-18T11:38:00Z")

</div>

&nbsp;

Yes it's true, the fileTreeComponent pointer should be accessible from the FileBrowserComponent class to allow drag and drop.

&nbsp;

I found a solution to do that without overriding the class.

I simply took the DirectoryContentsDisplayComponent pointer and casted it as a FileTreeComponent to call setDragAndDropDescription.&nbsp;

Make sure you pass the 'useTreeView' flag in the FileBrowserComponent constructor.

&nbsp;

```
FileTreeComponent* pTreeComponent = static_cast<FileTreeComponent*> (mFileBrowserComp->getDisplayComponent());

    if(pTreeComponent)
    {
        pTreeComponent->setDragAndDropDescription("DragAndDrop");
    }
```
