mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-03 23:12:42 +00:00
bef5dd37c4
* Applied formatting * Fixed file encoding + Updated copyright year * Updated License * Fixed more file encoding * Copyright notice now shows the year the file was created
48 lines
1.8 KiB
C#
48 lines
1.8 KiB
C#
// Copyright © 2014 The CefSharp Authors. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
namespace CefSharp.WinForms.Example.Handlers
|
|
{
|
|
internal class MenuHandler : IContextMenuHandler
|
|
{
|
|
private const int ShowDevTools = 26501;
|
|
private const int CloseDevTools = 26502;
|
|
|
|
void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
|
|
{
|
|
//To disable the menu then call clear
|
|
// model.Clear();
|
|
|
|
//Removing existing menu item
|
|
//bool removed = model.Remove(CefMenuCommand.ViewSource); // Remove "View Source" option
|
|
|
|
//Add new custom menu items
|
|
model.AddItem((CefMenuCommand)ShowDevTools, "Show DevTools");
|
|
model.AddItem((CefMenuCommand)CloseDevTools, "Close DevTools");
|
|
}
|
|
|
|
bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
|
|
{
|
|
if ((int)commandId == ShowDevTools)
|
|
{
|
|
browser.ShowDevTools();
|
|
}
|
|
if ((int)commandId == CloseDevTools)
|
|
{
|
|
browser.CloseDevTools();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void IContextMenuHandler.OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame)
|
|
{
|
|
|
|
}
|
|
|
|
bool IContextMenuHandler.RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
} |