A tool to create a line

There already is a Tool.isEnabled property, so you really shouldn’t by trying to override it.

Try this tool, which is taken from a derivation of the Draggable Link sample:

  function DisconnectedLinkingTool() {
    go.LinkingTool.call(this);
    this.isUnconnectedLinkValid = true;
    this._fakeStartPort = null;
  }
  go.Diagram.inherit(DisconnectedLinkingTool, go.LinkingTool);

  DisconnectedLinkingTool.prototype.canStart = function() {
    if (!this.isEnabled) return false;
    var diagram = this.diagram;
    if (diagram === null || diagram.isReadOnly || diagram.isModelReadOnly) return false;
    if (!diagram.allowLink) return false;
    var model = diagram.model;
    if (!(model instanceof GraphLinksModel) && !(model instanceof TreeModel)) return false;
    // require left button & that it has moved far enough away from the mouse down point, so it isn't a click
    if (!diagram.lastInput.left) return false;
    // don't include the following check when this tool is running modally
    if (diagram.currentTool !== this) {
      if (!this.isBeyondDragSize()) return false;
    }
    var port = this.findLinkablePort();
    if (port === null) {
      var $ = go.GraphObject.make;
      this._fakeStartPort = this.startObject =
        $(go.Shape, { width: 1, height: 1, portId: "", fromLinkable: true });
      var node =
        $(go.Node,
          { layerName: "Tool", locationSpot: go.Spot.Center, location: diagram.firstInput.documentPoint },
          this.startObject);
      diagram.add(node);
      node.ensureBounds();
    }
    return true;
  };

  DisconnectedLinkingTool.prototype.insertLink = function(fromnode, fromport, tonode, toport) {
    if (this._fakeStartPort !== null) {
      fromnode = fromport = null;
    }
    var link = go.LinkingTool.prototype.insertLink.call(this, fromnode, fromport, tonode, toport);
    if (link !== null) link.defaultFromPoint = this.diagram.firstInput.documentPoint.copy();
    return link;
  };

  DisconnectedLinkingTool.prototype.doStop = function() {
    if (this._fakeStartPort !== null) {
      this.diagram.remove(this._fakeStartPort.part);
      this._fakeStartPort = null;
    }
    go.LinkingTool.prototype.doStop.call(this);
  };
  // end of DisconnectedLinkingTool

Install with:

myDiagram.toolManager.mouseMoveTools.insertAt(2, new DisconnectedLinkingTool());