Custom Context Menu click issue

I am using the custom context menu based on the reference https://gojs.net/latest/samples/customContextMenu.html

Context menu is showing and hiding based on the button click and positioning also works fine. The only issue is click, currently the context menu shows only on right click. But i need to show the context menu just on click instead of right click.

Please any reference to implement on click behaviour.

Does this help? How to popup context menu at specific location of each node?

I have check the above link and can you tell me where to call the below function. Also, after adding the below function will it work on click.
contextClick : function(e) { //Disable contextMenu on right click
e.handled = true;
}

Does this do what you want?

      $(go.Node, . . .,
        {
          contextMenu:
            $("ContextMenu",
              $("ContextMenuButton",
                . . .)
            ),
          click: function(e, node) { e.diagram.commandHandler.showContextMenu(node); },
          contextClick: function(e, node) { e.handled = true; }
        },
        . . .

I am using custom context menu and not ContextMenuButton. https://gojs.net/latest/samples/customContextMenu.html

Shall I call the same for that as well.
click: function(e, node) { e.diagram.commandHandler.showContextMenu(node); },
contextClick: function(e, node) { e.handled = true; }

That works fine too:

      myDiagram.nodeTemplate =
        $(go.Node, "Auto",
          {
            contextMenu: myContextMenu,
            click: function(e, node) {
              e.diagram.commandHandler.showContextMenu(node);
            },
            contextClick: function(e, node) { e.handled = true; }
          },

However, you need to remove the addition of the “click” listener on the window. Or at least make it smarter. See the “// Optional:” comments.

        // Optional: Use a `window` click listener with event capture to
        //           remove the context menu if the user clicks elsewhere on the page
        //window.addEventListener("click", hideCX, true);

Thanks for the info. It works as expected.