FileBrowserComponent Drag and Drop request/idea

hello :slight_smile:
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 :wink:

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

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.


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.


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


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. 

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


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