Dragging and selecting if Node is in a Group

Hi Walter,
I found out that modifying the ClickSelectingTool is not all, if I want that a click on a node selects it’s group at first!
If I start to drag a node that is in a group I want also to move the group instead of the node. If the node is selected than the user should be able to move it, but if it is not selected than the drag should not select the node but the group and drag the group instead.

Is this possible?

Yes, you can override the behavior of DraggingTool. Here’s the definition of one of its (overridden) methods:

    protected override void StandardMouseSelect() {
      Diagram diagram = this.Diagram;
      if (diagram == null || !diagram.AllowSelect) return;
      this.CurrentPart = FindPartAt(diagram.FirstMousePointInModel, true);
      if (this.CurrentPart == null) return;

      // change behavior of StandardMouseSelect because we don't want the Control modifier to unselect
      // an already selected object
      if (!this.CurrentPart.IsSelected) {
        if (!IsControlKeyDown() && !IsShiftKeyDown()) {
          diagram.ClearSelection();
        }
        this.CurrentPart.IsSelected = true;
      }
    }

The reason for that method already being overridden in DraggingTool is to handle the control key. I don’t know what you want to do about the control key, but I suspect that you can at least decide to also select the containing group (or not) according to the conditions at the time that this method is called, which is at the beginning of DraggingTool.DoActivate.

You might want to override DraggingTool.ComputeEffectiveCollection, but I’m not sure what you want to do.

This will help, thank you.