TreeViewItem Drag and Dropped to external program

I am trying to add a FileBrowserComponent within my plugin (tested on Linux and Reaper), from which I want to drag and drop tree view items (files) to Reaper as MIDI tracks. For this purpose, what I’ve managed to do so far is inheriting the PluginEditor class from FileBrowserListener, and when a file is clicked, I create an instance of a class called TreeViewItemComponent, which is supposed to contain a pointer to the item (file) already clicked. All of the item references are stored in a vector contained in the editor class.

The TreeViewItemComponent.h class:

class TreeViewItemComponent : public juce::Component
{
public:
    TreeViewItemComponent(juce::TreeViewItem* p_creatorItem, juce::File p_dragableFile)
    {
        creatorItem = p_creatorItem;
        dragableFile = p_dragableFile;
    }

    void mouseDown(const juce::MouseEvent &e) override
    {
        componentBeingDragged.startDraggingComponent(this, e);
    }

    void mouseDrag(const juce::MouseEvent &e) override
    {
        componentBeingDragged.dragComponent(this, e, nullptr);
    }

    void mouseUp(const juce::MouseEvent &e) override
    {
        juce::DragAndDropContainer::performExternalDragDropOfFiles(dragableFile.getFullPathName(), false, nullptr);
    }

     ...

private:

    juce::ComponentDragger componentBeingDragged;
    juce::TreeViewItem* creatorItem;

    juce::File dragableFile;

    ...
};

The PluginEditor.h class:

class HarmonizationmachineAudioProcessorEditor  : public juce::AudioProcessorEditor, 
                                                  private juce::FileBrowserListener
{
public:
    ...
    void fileClicked (const juce::File&, const juce::MouseEvent&) override;

private:
    ...
    juce::TimeSliceThread thread  { "file tree browser" };
    juce::DirectoryContentsList directoryList {nullptr, thread};
    juce::FileTreeComponent inputFileBrowser {directoryList};
    std::vector<TreeViewItemComponent*> itemVector;
};

The PluginEditor.cpp class:

...

 HarmonizationmachineAudioProcessorEditor::HarmonizationmachineAudioProcessorEditor(HarmonizationmachineAudioProcessor &p)
    : AudioProcessorEditor(&p), audioProcessor(p)
{
    ...
    addAndMakeVisible(inputFileBrowser);
    directoryList.setDirectory(juce::File::getSpecialLocation(juce::File::userHomeDirectory), true, true);
    inputFileBrowser.setDragAndDropDescription("draggedFromPlugin");
    inputFileBrowser.addListener(this);
    thread.startThread(3); 
}

void HarmonizationmachineAudioProcessorEditor::fileClicked(const juce::File &file, const juce::MouseEvent &) 
{
    itemVector.push_back(new TreeViewItemComponent(inputFileBrowser.getSelectedItem(0), file));
}

I also debugged everything, and it creates instances of the TreeViewItems clicked normally but doesn’t trigger any of the mouse events implemented.

My code is based on this post and on this JUCE example.

I appreciate any kind of help :slight_smile: