diff --git a/Source/WebInspectorUI/UserInterface/Base/Main.js b/Source/WebInspectorUI/UserInterface/Base/Main.js index 8faadc7a2..c03899d4d 100644 --- a/Source/WebInspectorUI/UserInterface/Base/Main.js +++ b/Source/WebInspectorUI/UserInterface/Base/Main.js @@ -221,6 +221,7 @@ WI.contentLoaded = function() window.addEventListener("resize", WI._windowResized); window.addEventListener("keydown", WI._windowKeyDown); window.addEventListener("keyup", WI._windowKeyUp); + window.addEventListener("mousedown", WI._mouseDown, true); window.addEventListener("mousemove", WI._mouseMoved, true); window.addEventListener("pagehide", WI._pageHidden); window.addEventListener("contextmenu", WI._contextMenuRequested); @@ -1876,6 +1877,23 @@ WI._windowKeyUp = function(event) WI._updateModifierKeys(event); }; +WI._mouseDown = function(event) +{ + if (event.button === 2) { // right-click + const contextMenuEvent = new MouseEvent("contextmenu", { + view: window, + bubbles: true, + cancelable: true, + screenX: event.pageX, + screenY: event.pageY, + clientX: event.pageX, + clientY: event.pageY, + ...event + }); + event.target.dispatchEvent(contextMenuEvent); + } +}; + WI._mouseMoved = function(event) { WI._updateModifierKeys(event); diff --git a/Source/WebInspectorUI/UserInterface/Views/ContextMenu.js b/Source/WebInspectorUI/UserInterface/Views/ContextMenu.js index a16465d11..1ef757775 100644 --- a/Source/WebInspectorUI/UserInterface/Views/ContextMenu.js +++ b/Source/WebInspectorUI/UserInterface/Views/ContextMenu.js @@ -212,7 +212,7 @@ WI.ContextMenu = class ContextMenu extends WI.ContextSubMenuItem this._event.target.addEventListener("contextmenu", this, true); InspectorFrontendHost.dispatchEventAsContextMenuEvent(this._event); } else - InspectorFrontendHost.showContextMenu(this._event, menuObject); + this._showSoftContextMenu(this._event, menuObject); } if (this._event) @@ -234,7 +234,7 @@ WI.ContextMenu = class ContextMenu extends WI.ContextSubMenuItem callback(this); this._event.target.removeEventListener("contextmenu", this, true); - InspectorFrontendHost.showContextMenu(event, this._menuObject); + this._showSoftContextMenu(event, this._menuObject); this._menuObject = null; event.stopImmediatePropagation(); @@ -262,6 +262,11 @@ WI.ContextMenu = class ContextMenu extends WI.ContextSubMenuItem WI.reportInternalError(e); } } + + _showSoftContextMenu(event, menuObject) + { + new WI.SoftContextMenu(menuObject).show(event); + } }; WI.ContextMenu.ProposedMenuSymbol = Symbol("context-menu-proposed-menu");