Dragging between two Diagrams with a Custom Dragging Tool

So you have a variable number of similar diagrams, and drag-and-drop can happen between any of them? That should mean that for each Diagram you create, you replace its ToolManager.draggingTool with a new instance of your DraggingTool.

As I said above, when a drag-and-drop starts, it is the source diagram’s DraggingTool that is running, until the operation stops (either successfully or canceled). Note that there are really three Diagrams that might be relevant at any given time: the source diagram (whose Diagram.currentTool is the running DraggingTool), the diagram that the mouse has just left (if any), and the diagram that the mouse is over (if any). We don’t make these diagrams available as read-only properties in the API, but maybe we should.

You can find the source diagram via the undocumented read-only DraggingTool.draggingSource property, which is either a DraggingTool or null. That property is set when the isDragOutStarted property is set, which happens at the end of the doActivate method when allowDragOut is true, which obviously had better be true for any of this to work.

You can find the target diagram in your overrides of doMouseMove and doMouseUp by evaluating: this.diagram.lastInput.targetDiagram

I think when the mouse isn’t over any diagram viewport the value will be the source diagram, since that’s the value it will have while the mouse is inside the source diagram viewport.