Close the already opened Custom menu handler when click on Cefsharp webbrowser container

Question

I am developing WPF application using cefsharp chromium web browser as a browser control. In my App, when right click on the Cefsharp browser I would like to show some controls and I am able to show the controls. When I right click, open the custom menu and click on container then I am not able to close the custom menu.

My Code is

 _cefchrbrowser.Address = _address;
 _cefchrbrowser.MenuHandler = new CustomMenuHandler();

My Class is

public class CustomMenuHandler : IContextMenuHandler
{
    public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
    {
        model.Remove(CefMenuCommand.ViewSource);
        model.Remove(CefMenuCommand.Print);
        model.Remove(CefMenuCommand.Undo);
        model.Remove(CefMenuCommand.Redo);
    }

    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;
    }
}

Without selecting any custom menu item when I click on browser, am not able to close the menu. Can you Please Check out the issue once and help me Please.

Thanks in advance.


Show source
| wpf   | winforms   | cefsharp   2016-12-24 15:12 0 Answers

Answers to Close the already opened Custom menu handler when click on Cefsharp webbrowser container ( 0 )

Leave a reply to - Close the already opened Custom menu handler when click on Cefsharp webbrowser container

◀ Go back