Hi, i have a question
I’m dragging a link from a port on a node to connect it to the port on the other node, but i drop the link in the diagram before i connect to the other node, can i catch that drop event with the info which node i’m dragging from?
I did like you recommended. this is the code :
http://jsfiddle.net/thanhvu231/ufVUr/4/
I created a custom LinkingTool at the line 303 in the javascript file in the jsfiddle above and try to alert text to see whether it runs or not.
Could you have a look at the CustomLinkingTool and give me some have advice. In this case, i want to catch the failed link when i mouse-up.
Thanks
walter
April 1, 2013, 3:08pm
2
You had a typo, causing your custom tool not to be used instead of the standard LinkingTool.
Furthermore I have edited the code to do what I think you were trying to do:
function CustomLinkingTool() {
go.LinkingTool.call(this);
}
go.Diagram.inherit(CustomLinkingTool, go.LinkingTool);
myDiagram.toolManager.linkingTool = new CustomLinkingTool();
CustomLinkingTool.prototype.doMouseUp = function() {
if (this.isActive && this.findTargetPort(this.isForwards) === null) {
alert(“No link created”);
this.doCancel();
} else {
go.LinkingTool.prototype.doMouseUp.call(this);
}
};
When nothing seems to have changed and JavaScript is involved, always check for typos.
Great…i really appreciate that :)
Hi, i have another question
when i caught failed link, can i know the position where the mouse do mouse-up or can i have an event variable as in other mouseup function?
walter
April 3, 2013, 6:44am
5
this.diagram.lastInput.documentPoint
Thanks. One more thing, in the CustomLinkingTool if it can find the valid port instead of calling the linking tool i want to connect originalfromNode to the temporaryToNode through the whole node as i want not to the port i chose in the first place but i don’t know why the temporaryToNode.data is null while i the temporaryToNode exists
CustomLinkingTool.prototype.doMouseUp = function() {
if (this.isActive && this.findTargetPort(this.isForwards) === null) {
<span =“apple-tab-span”=“” style=“white-space:pre”>
} else {
//go.LinkingTool.prototype.doMouseUp.call (this);
<span =“apple-tab-span”=“” style=“white-space:pre”>
<span =“apple-tab-span”=“” style=“white-space:pre”> // this.temporaryToNode.data == null ======> ???
<span =“apple-tab-span”=“” style=“white-space:pre”>
}
};
walter
April 3, 2013, 10:29am
7
I believe the temporary Nodes and temporary Link are not data bound. They are not part of the Diagram.model, and you would not want them to be.