Dragging from a connected port

Hi,
I have a node containing several ports. Each port can have a single link.
When the port is not connected, dragging from the port enters in “link creation” mode, which is correct.
But, I would like to extend the current functionality to support the following behaviour: “When the port is already connected, dragging from it, should enable drag and drop to an aditional windows application.” - The node/port should not be moved, but the mouse icon should change to show a drag&drop operation and the port data, should be placed in the clipboard.
Any advice is greatly appreciated
All the best
Paullie

When you want to customize the interactive behavior of a GoView, you need a custom tool. That means either setting some properties or overriding some methods of an existing tool class (and replacing that tool in the view’s appropriate list of mouse tools), or defining your own new tool class.
Although you could customize GoToolDragging, it might be easier and cleaner for you to just define your own and install it as the first tool in GoView.MouseMoveTools:
goView1.MouseMoveTools.Insert(0, new CustomDragTool(goView1));
You’d implement it something like:
public class CustomDragTool : GoTool {
public CustomDragTool(GoView view) : base(view) {}
public override bool CanStart() {
if (!this.View.AllowDragOut || this.LastInput.IsContextButton) return false;
GoPort port = this.View.PickObject(true, false, this.FirstInput.DocPoint, false) as GoPort;
return (port != null && port.LinksCount > 0);
}
public override void Start() {
GoPort port = this.View.PickObject(true, false, this.FirstInput.DocPoint, false) as GoPort;
if (port != null && port.LinksCount > 0) {
this.CurrentObject = port;
this.View.DoDragDrop(…); // figure out what data to transfer
}
}
public override void Stop() {
this.CurrentObject = null;
}
}
Some things you might need to consider:
Are you modifying the document at all in this tool? If so, you’ll need to call StartTransaction in the Start method and StopTransaction in the Stop method sometime after setting the TransactionResult property.
What happens when the user just clicks on such a port? Since I suggested that this be in the MouseMoveTools list, it will only be started when the user drags the mouse. But maybe you want to handle the click case this way, or perhaps a different way.
What happens when the user drags from such a port, and then drops in this view? Or leaves the GoView and then returns? Or cancels the drag? Maybe you won’t need to do anything, but you need to plan for all kinds of cases.