Drop shape from palette on another node

Walter & Co.,

Is there any way that when a node is dropped from the palette onto the diagram, and you drop the dragged node directly onto a another node, can that dropped node automatically be made a child of the node you dropped it upon?

I think I’ve seen an example with this, but I can’t for the life of me dig it up. I’d like to eliminate the step of explicitly linking 2 shapes, if the “drop intent” indicates that the user wishes to make the new child node under the target node…


Look at the mouseDrop event handler on the Node template. But the template also defines mouseDragEnter and mouseDragLeave event handlers to provide visual feedback during the drag. Note that all of those functions call a predicate function (called “mayWorkFor”) to check whether that particular drop & link connection is valid.

Those event handler properties are actually defined on GraphObject: http://gojs.net/latest/api/symbols/GraphObject.html.