From 7ad28fbc244cd537fc58d31ffd988e740c5f3dfa Mon Sep 17 00:00:00 2001 From: Natsumi Date: Fri, 18 Mar 2022 02:19:39 +1300 Subject: [PATCH] Remove default context menu --- CefCustomMenuHandler.cs | 34 ++++++++++++++++++++++++++++++++++ MainForm.cs | 1 + VRCX.csproj | 1 + 3 files changed, 36 insertions(+) create mode 100644 CefCustomMenuHandler.cs diff --git a/CefCustomMenuHandler.cs b/CefCustomMenuHandler.cs new file mode 100644 index 00000000..f21ff2bd --- /dev/null +++ b/CefCustomMenuHandler.cs @@ -0,0 +1,34 @@ +// Copyright(c) 2019 pypy. All rights reserved. +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +using CefSharp; + +namespace VRCX +{ + public class CustomMenuHandler : IContextMenuHandler + { + public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) + { + // remove default right click + if (!parameters.TypeFlags.HasFlag(ContextMenuType.Selection)) + model.Clear(); + } + + public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) + { + return false; + } + + public void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame) + { + + } + + public bool RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback) + { + return false; + } + } +} \ No newline at end of file diff --git a/MainForm.cs b/MainForm.cs index fe5bf6d4..595e701b 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -43,6 +43,7 @@ namespace VRCX ) { DragHandler = new NoopDragHandler(), + MenuHandler = new CustomMenuHandler(), BrowserSettings = { DefaultEncoding = "UTF-8", diff --git a/VRCX.csproj b/VRCX.csproj index 602af864..a9af5232 100644 --- a/VRCX.csproj +++ b/VRCX.csproj @@ -81,6 +81,7 @@ +