Changing key actions while dragging

Hello,



We’re in the process of evaluating the GoXam component and we’re liking what we’ve seen so far. However, it would be nice if you could override the key actions. For example, currently holding control and dragging a node takes a copy of the node. It would be nice if say holding shift and dragging a node created a link and just dragging a node (without any key pressed) moved it. I know you can set up a spot panel and have ports but it would be nice if you could select the whole node as a connection point. If you do this currently you can’t then drag the node around.



Cheers,



Mr B

That’s easy to do. I modified the StateChart sample by adding these two custom tools:

[code] public class CustomDraggingTool : DraggingTool {
public override bool CanStart() {
if (IsShiftKeyDown()) return false;
return base.CanStart();
}
}

public class CustomLinkingTool : LinkingTool {
protected override FrameworkElement FindLinkablePort() {
if (!IsShiftKeyDown()) return null;
Node node = FindPartAt(this.Diagram.FirstMousePointInModel, true) as Node;
if (node != null && IsValidFrom(node, node.VisualElement)) return node.VisualElement;
return null;
}
}[/code]
I replaced the standard tools by adding the following statements in the constructor:

myDiagram.DraggingTool = new CustomDraggingTool(); myDiagram.LinkingTool = new CustomLinkingTool();
Or you could do this in XAML.

The result is that an unmodified drag moves a node, a control-drag copies it, and a shift-drag doesn’t move but instead starts drawing a new link.

I didn’t bother, but one could then also simplify the node DataTemplate by removing the go:Node.LinkableFrom=“False” and go:Node.LinkableTo=“False” from the TextBlock.

That’s awesome that, just what I was after.



Thanks.