Skip to content

Fix ListBox drag-to-DAW, audio preview error feedback, and import filename preservation#24

Merged
lmangani merged 2 commits into
mainfrom
copilot/fix-drag-and-drop-audio-functionality
Mar 22, 2026
Merged

Fix ListBox drag-to-DAW, audio preview error feedback, and import filename preservation#24
lmangani merged 2 commits into
mainfrom
copilot/fix-drag-and-drop-audio-functionality

Conversation

Copilot AI commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Three bugs in the Library tab: drag-to-DAW never initiates, audio preview fails silently, and imported files are renamed with a timestamp instead of keeping their original name.

Drag-and-drop (root cause)

LibraryListBox overrode mouseDown/mouseDrag/mouseUp directly on the ListBox subclass. JUCE routes all row interactions through an internal ContentComponent (nested child of ListViewport), so those overrides never fire for row events — dragRow_ was permanently -1.

Fix: Replace the three overrides with a DragHelper : public juce::MouseListener registered via addMouseListener(&dragHelper_, true). The true flag captures events from all nested descendants. Coordinates are translated with e.getEventRelativeTo(&lb_) before calling getRowContainingPosition(). Drag is initiated via the static DragAndDropContainer::performExternalDragDropOfFiles() directly — no fragile parent-container lookup.

// Before: overrides on ListBox that JUCE never calls for row events
void LibraryListBox::mouseDrag(const juce::MouseEvent& e) {
    auto* container = juce::DragAndDropContainer::findParentDragContainerFor(this);
    if (container && container->performExternalDragDropOfFiles(...)) { ... }
}

// After: listener that receives events from the internal ContentComponent
void LibraryListBox::DragHelper::mouseDrag(const juce::MouseEvent& e) {
    // ...
    juce::DragAndDropContainer::performExternalDragDropOfFiles(
        juce::StringArray(path), false, &lb_);
    dragStarted_ = true;
}
// Registered in constructor:
addMouseListener(&dragHelper_, true);

Audio preview error feedback

previewLibraryEntry() was void and failed silently on bad format or missing file. Changed to return bool; onPreviewClicked() now calls showFeedback("Preview failed…") on failure.

Import filename preservation

importAudioFile() renamed every imported file to import_YYYYMMDD_HHMMSS.ext. Fixed to use the original filename, appending _N (capped at 1000) only on collision.


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI changed the title [WIP] Fix drag-and-drop functionality for AUDIO files in plugin Fix ListBox drag-to-DAW, audio preview error feedback, and import filename preservation Mar 22, 2026
Copilot AI requested a review from lmangani March 22, 2026 22:16
@lmangani
lmangani marked this pull request as ready for review March 22, 2026 23:01
@lmangani
lmangani merged commit 8be67db into main Mar 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants