Dropping a node on Link

Hi, we have been using GoJS for last 3 years.
I’ve a diagram with nodes and links. I also have a palette full of nodes. All I want is, If I drag and drop any node from the palette or any existing node in the diagram itself onto any link, then I should get any event, which would give me both the dropped node and the target link. Dropped node I can fetch from diagram.selection, how do I get the link onto which I dropped the node?

I tried patching mouseDrop event in the link template, but it doesn’t work(doesn’t get called), mouseDragEnter and mouseDragLeave do work, but don’t think they can help.

Please suggest any simple way out

The GraphObject.mouseDrop event handler should be called. Certainly if you are finding that the GraphObject.mouseDragEnter and GraphObject.mouseDragLeave events are being called, the mouseDrop event should happen as well.

Hi Walter,
so I am using go.GraphObject.make. In the link template, I’ve specified the events, but mouseDrop doesn’t get called. Also the links are set to go.Link.JumpOver
Below is my link template:

        go.Link, { relinkableFrom: true, relinkableTo: true },
            new go.Binding("routing", "routing"),
            new go.Binding("corner", "corner"),
            new go.Binding("curve", "curve"),
        $goJs(go.Shape, { strokeWidth: 2 }, new go.Binding("stroke", "Color")),
        $goJs(go.Shape, { toArrow: "Standard" }, new go.Binding("fill", "Color")),
            new go.Binding("text", "Name"),
            new go.Binding("visible", "IsVisible"),
            { width: 50, stroke: "black", font: "Bold 11px Sans-Serif" }),
            contextMenu: $goJs(go.Adornment),
                    $goJs(go.Shape, { isPanelMain: true, stroke: null }),
                    $goJs(go.Shape, { toArrow: "Standard", fill: null, stroke: null })),
            mouseDrop: function (e, l) {

I am using GoJS v1.4.23

I just tried your link template, unmodified, in a copy of the Flow Chart sample. It worked as I expected, getting an alert.

Perhaps you are not dropping the node on the link? Only the mouse point is used for hit-testing whether the drop happened “onto” a link.

Note how in some samples there is feedback, implemented using mouseDragEnter and mouseDragLeave event handlers, so that the user can tell whether they are “over” a link.

ahh it workd, so the way I was able to raise the event, when I actually took my mouse pointer on the link, as if it simply doesn’t care about the bounds (measurement) of the node. I think I will make it work, but if I were to detect a link based on proximity, is there any useful built-in method (like jQuery’s closest)? I have so far been trying to do that by manipulating the location property

Call Diagram.findObjectsIn or Diagram.findObjectsNear.

The reason for only depending on the mouse point is that it would otherwise be very ambiguous what to do when the dropped node(s) happen to cover 17 different links (or nodes or whatever) that all have (perhaps different) event handlers.

This helps, thanks for your time Walter