Mouse middle click on textBlock

Hi

I’m trying to find the way to implement link behavior, like html <a> tag works.
There is no issue with mouseClick event, but I also need to handle a “middle” click, which in html for <a> by default opens a new tab in browser.
Is there a way to handle that?

Thanks
Vlad.

Override ClickSelectingTool.standardMouseClick, call the super method for the standard behavior, and then check for InputEvent.middle.

    $(go.Diagram, "myDiagramDiv",
      {
        "clickSelectingTool.standardMouseClick": function(navig, pred) {
          var result = go.ClickSelectingTool.prototype.standardMouseClick.call(this, navig, pred);
          if (this.diagram.lastInput.middle) {
            // can look at this InputEvent.targetObject to see exactly what was clicked
            var elt = this.diagram.lastInput.targetObject;
            alert("middle button on " + elt ? elt.part.key : "");
          }
          return result;
        },
        . . .

Thanks Walter.

Walter, it works perfectly every where except tooltip. this.diagram.lastInput.targetObject is null in case of i’m clicning something inside tooltip. I’m clicking textblock inside tooltip. Tooltip is made as Adornment.

I haven’t tried this, but you could try instead:

var result = go.ClickSelectingTool.prototype.standardMouseClick.call(this, null, null);
1 Like

That works Walter, thanks.