FileTreeComponent drag and drop misunderstanding


#1

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


#2

Hey Colin

Take a look at the DragAndDropContainer class.

and the DragAndDropTarget

Hope that points you in the right direction.


#3

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

-Colin


#4