Tool CanStart

I would like to amend the defult LinkingTool’s canStart so that it only starts if the Shift key is currently down.

I’m sure I’ve seen something somewhere - but I may be confused with something else.

Do you have the functionality to test if the Control or Shift or Alt key is down from within the canStart method of the Tool ?

Thanks.

Gary.

You can override the LinkingTool.canStart method:

[code] function ShiftLinkingTool() {
go.LinkingTool.call(this);
}
go.Diagram.inherit(ShiftLinkingTool, go.LinkingTool);

ShiftLinkingTool.prototype.canStart = function() {
if (!go.LinkingTool.prototype.canStart.call(this)) return false;
return this.diagram.lastInput.shift;
};[/code]
Then you can replace the Diagram’s standard LinkingTool:

myDiagram.toolManager.linkingTool = new ShiftLinkingTool();

hello walter,
I want to send the incoming event to the beginning of the link to start the drag.

this.Diagram.toolManager.draggingTool.canStart = function (): boolean {
if (this.diagram.lastInput && this.diagram.lastInput.shift) {
console.log(“canStartLinking”);
//Run link drawing start
return false;
}

        else {
            return go.DraggingTool.prototype.canStart.call(orjinalDraggingTool);
        }

    }

Tool.canStart is called to see if that Tool should start running as the Diagram.currentTool. Even if the predicate were to return true, the tool is not yet running. And once it is running does not mean it is active.

You can override either Tool.doStart or Tool.doActivate to implement custom behavior at those respective times.