Remove default context menu

This commit is contained in:
Natsumi
2022-03-18 02:19:39 +13:00
parent 23c12024f4
commit 7ad28fbc24
3 changed files with 36 additions and 0 deletions

34
CefCustomMenuHandler.cs Normal file
View File

@@ -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 <https://opensource.org/licenses/MIT>.
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;
}
}
}

View File

@@ -43,6 +43,7 @@ namespace VRCX
)
{
DragHandler = new NoopDragHandler(),
MenuHandler = new CustomMenuHandler(),
BrowserSettings =
{
DefaultEncoding = "UTF-8",

View File

@@ -81,6 +81,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AssetBundleCacher.cs" />
<Compile Include="CefCustomMenuHandler.cs" />
<Compile Include="ImageCache.cs" />
<Compile Include="VRCEventDeserialization.cs" />
<Compile Include="IPCClient.cs" />