Is your context menu implemented as a GoJS Adornment, or is it implemented as HTML?
I don’t understand the exact sequence of actions I need to take in order to reproduce the problem. Do you see the behavior if you run Basic | GoJS or Context Menu | GoJS ?
After more investigation I have two issues in fact
The first one, if we left click and right after we right click, the context menu is not showing up before a certain delay (need to click again) and in local, it show up but the button is not working (but if I reopen it after a certain delay, it works)
Two left clicks close together in time results in a double-click event.
But unless you handle click or doubleClick events to cause a context menu to appear, I don’t see how two (left) clicks would cause a context menu to show.
Note that a “click” requires a mouse or finger down event soon followed by an up event without moving too far away. How “soon” a second click results in a double-click is determined by the system. The distance between the clicks is controlled by ToolManager | GoJS API.
I assumed by “right after” you actually meant to say “soon after” or “immediately after”, not after a right-click.
OK, so if you meant to describe a left-click followed as soon as you could by a right-click at the same point, I can try to duplicate that to see if there are any surprises that cause a contextClick not to occur.
When the user first does a left click, InputEvent.clickCount is 1. If the user then quickly does another left click, InputEvent.clickCount is 2, and the second click is considered a double-click.
If the user first does a left click and then quickly does a right click, that second click also has InputEvent.clickCount == 2. By convention a right click cannot be a context-click if clickCount > 1 – i.e. when it’s a double-click or a triple-click. This is normally desired to avoid extra context click events if the user accidentally does two or more right clicks quickly.
In your situation there is a left click and then a quick right click. I can see why you would want to treat that right-double-click as wanting to invoke a context menu. But I hope you can see why the rule had always been that right-double-clicks never invoke a context menu. I don’t know that we want to change this behavior.
But you can change the implementation of the ContextMenuTool by overriding the ContextMenuTool.canStart method:
new go.Diagram("myDiagramDiv",
{
"contextMenuTool.canStart": function() {
if (!this.isEnabled) return false;
const diagram = this.diagram;
if (this.isBeyondDragSize()) return false;
if (!diagram.lastInput.right) return false;
//if (diagram.lastInput.clickCount > 1) return false;
if ((diagram.lastInput.isTouchEvent && this.defaultTouchContextMenu !== null) ||
this.findObjectWithContextMenu() !== null) return true;
return false;
},
. . .
That is the definition of ContextMenuTool.canStart with the check for InputEvent.clickCount commented out.
Note that overriding a method on ContextMenuTool has no effect on the raising of any “…ContextClicked” DiagramEvent or on calling of any contextClick property.