mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 11:42:36 +00:00
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
// Copyright © 2010-2015 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
|
|
{
|
|
// TO DO: Create enum for Command Id values
|
|
internal class MenuHandler : IContextMenuHandler
|
|
{
|
|
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(132); // Remove "View Source" option
|
|
|
|
//adding new menu item
|
|
model.AddItem(102, "Reload");
|
|
}
|
|
|
|
bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, int commandId, CefEventFlags eventFlags)
|
|
{
|
|
if (commandId == 102)
|
|
{
|
|
browser.Reload();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void IContextMenuHandler.OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |