Snap to grid only inside group node

I am trying to implement a group node template with category “GroupA” with grid snapping for only group category “GroupA” and no node of it allowed to go out of group, only the nodes inside to have grid snapping and rest of diagram to behave normally. also the group to have nodes in tree layout spacing 0.


There is only one instance of DraggingTool, so it operates everywhere in the diagram. In other words, each group doesn’t have a different DraggingTool.

Besides setting properties or overriding methods of the DraggingTool, you can affect dragging behavior by setting properties on the parts (i.e. nodes) that are dragged. The easiest way to restrict the movement of a node not to go beyond a certain variable area is to set its Part.dragComputation property to a function similar to stayInGroup that you can find in some samples. You would at least need to make sure that function does not limit its return value, a Point in document coordinates, when the Node is not in the kind of Group that you care about.

Makes sense! Thanks Walter