I’m having a hard time figuring out what is the best approach to use the FileBrowserComponent on iOS, to provide classic list-browsing and drag’n’dropping from the browser onto other UI components.
If I use the FileBrowserComponent in tree view mode, it clashes between scrolling the list and starting the drag’n’drop gesture. So if there’s more items in the list, the scroll drag works sometimes, but you can see it starting to drag the row temporarily.
Without tree view mode, drag’n’drop is simply not supported by the internal ListBox.
What’s the best approach so far to enable scrolling of the content, and drag’n’dropping ?
Really wish JUCE can support drag&drop for iOS, especially in AUv3, it’s definitely do-able (please see Koala Sampler), and this will open up the possibility of 3rd party file management for users.
After digging into the depth of FileBrowserComponent, when tree mode view is disabled, it uses a FileListComponent (which inherits from ListBox), the ListBox::RowComponent itself properly detects a scroll gesture on its viewport vs. a drag’n drop gesture.
This can be seen in the code of ListBox::RowComponent:
void mouseDrag (const MouseEvent& e) override
{
if (auto* m = owner.getModel())
{
if (isEnabled() && e.mouseWasDraggedSinceMouseDown() && ! isDragging)
{
[...]
However this method is never called, since FileListComponent implements its own row/item class (FileListComponent::ItemComponent). This ItemComponent class has no support for dragging/drag’n’dropping like the ListBox::RowComponent class.
I believe the bulk of the work would reside in adding all the scroll/drag detection code within FileListComponent.
So far this seems to be the most straightforward method, unless I’m missing something. Happy to hear the JUCE dev team thoughts about this possible improvement.