I've got a BrowserFileComponent component on my interface and I would like a drop files into the FileTreeComponent but this looks very difficult to do.
When I drop items into it, I can see that TreeView::handleDrop is called:
void TreeView::handleDrop (const StringArray& files, const SourceDetails& dragSourceDetails)
{
hideDragHighlight();
InsertPoint insertPos (*this, files, dragSourceDetails);
if (insertPos.item == nullptr)
insertPos.item = rootItem;
if (insertPos.item != nullptr)
{
if (files.size() > 0)
{
if (insertPos.item->isInterestedInFileDrag (files))
insertPos.item->filesDropped (files, insertPos.insertIndex);
}
else
{
if (insertPos.item->isInterestedInDragSource (dragSourceDetails))
insertPos.item->itemDropped (dragSourceDetails, insertPos.insertIndex);
}
}
}
but isInterestedInDragSource§isInterestedInFileDrag always return false.
If I want to change this return, no other change that overriding, is it?
I though that I could easily override FileBrowerComponent and its child classes.
I first tried to overridde FileBrowerComponent but I don't manage to override the constructor as the FileBrowerComponent class inherites from FileFilter which is private...
So unless rewrite all thoses classes (FileBrowser, FileTreeComponent, FileTreeView, FileTreeItem,...), I can't see how to do that.
So my question is simply: Is there an easy way to drop items into the FileTreeComponent ?
Yes, there's not really any way to do it with those existing classes - I didn't really design them to be extensible like that, they were just for displaying the file tree, not editing it. You'd probably need to write your own special file tree if you want it to support that kind of operation.
Well I finished by overriding mouseUp on my main component. I found the destination folder by calling getItemIdentifierString() on a fileTreeItem like this: