Drag and drop over multiple Document windows

In the application I’m working on, we use drag and drop to rearrange panes on the workspace. There’s a manipulator in the top left corner of each pane that we drag around and then drop the dragged pane in a space between other panes (see attached image).

Currently I’m implementing drag and drop behaviour between different undocked windows (which are regular document windows). The problem is that I don’t know how to correctly identify and switch drag and drop targets. When the dragged manipulator is dragged over another drag and drop container than the original one, there’s no way to switch to using the drag and drop container under the mouse cursor.

void WorkPaneManipulator::mouseDrag(
    const juce::MouseEvent &event)
    // I would like to identify the correct drag and drop container and switch to another drag
    // and drop container when the mouse goes over another one.
    juce::DragAndDropContainer *container = 
    OCTANE_ASSERT(container, "no drag & drop container found");


We're currently using JUCE v3.1.1, we've tested both Linux and Windows.

I am too insterested in this. What I need is to drag some components from one Juce window to another. I am not sure how to do this since cause I don't know what would DragAndDropContainer be in this case...

I finally got this working.

Each of my windows contains a component that does the layout and is also a juce::DragAndDropContainer. When I start a drag & drop operation, I simply use the parent of my dragged component as the drag & drop container.

To update my drag and drop state when going over multiple windows I'm using itemDragEnter and itemDragExit. In hindsight it was all very simple, my mistake was that I was trying to use dragOperationStarted() and dragOperationEnded() which is only called for the original drag container.


This still has an issue with windows which are always on top. If you drag over such a window, the drag events still go to the window behind that topmost window. This appears to be done on purpose (see eg. the calls to SetCapture in juce_win32_Windowing.cpp).

Any suggestions about how to make drag events go to the topmost window, rather than the window from which the drag originated?