Is it possible to prevent drop anywhere on diagram?

I was wondering if there is a way to prevent a drop from palette to a diagram that includes preventing to drop a node on another node. I saw that the diagram mouseDrop event is called only when the node isn’t dropped on some other node.

To simplify: I want to prevent a drop of a specific category anywhere on the diagram.

No one can control where the user does a mouse up after a drag. But you can handle a mouseDrop event, either on the Diagram or on any GraphObject, GraphObject | GoJS API.

If you care about the exact position of the mouse upon a drop, rather than just on a particula GraphObject, you can check the InputEvent.documentPoint.

If you care about what is being dropped, you can look at either the Diagram.selection collection or at the DraggingTool.draggedParts or copiedParts: e.diagram.toolManager.draggedParts.

You can then decide to let the drop complete normally, or modify the dropped objects, or delete them, or cancel the whole drag-and-drop by calling e.diagram.currentTool.doCancel(). Cancelling rolls back the transaction.

IN case of a large number of node templates, I’d need to implement mouseDrop, mouseLeave and mouseEnter for each one of them?

I’ll think about it… for the time being, I decided to just delete the node after it is dropped (in ExternalObjectsDropped)…

Tnx walter

Oh, that will work too. But you won’t be able to provide feedback during the drag unless you define mouseDragEnter and mouseDragLeave events or Diagram.mouseDragOver events.