0

How to disable context menu in cef sharp chromium browser and replace a new custom context menu that consists of only buttons

amaitland
  • 4,073
  • 3
  • 25
  • 63
Comp Droid
  • 21
  • 10
  • Possible duplicate of [How do I hide the CefSharp.WinForms.ChromiumWebBrowser right click context menu?](https://stackoverflow.com/questions/34244244/how-do-i-hide-the-cefsharp-winforms-chromiumwebbrowser-right-click-context-menu) – Anas Alweish May 22 '19 at 12:46
  • what have you researched and tried so far? – jtate May 22 '19 at 12:50
  • Iam trying to change the looks of the old context menu in cef chromium browser...now the context menu has only text ...Iam trying to put images...for example there is “back” option in the context menu...I must remove it and put a small icon which resembles “back” option – Comp Droid May 23 '19 at 18:26
  • That is not supported, you'll have to implement your own menu. If you are using WinForms you can implement http://cefsharp.github.io/api/73.1.x/html/M_CefSharp_IContextMenuHandler_RunContextMenu.htm then display your own – amaitland May 25 '19 at 21:40

1 Answers1

1

You implement the IContextMenuHandler interface, and then in IContextMenuHandler.OnBeforeContextMenu you call model.Clear();. Then you have to set your ChromiumWebBrowser's MenuHandler property to an instance of your implementation. From the code doc on that method (model.Clear()):

Remove all menu items. Can be used to disable the context menu.

rory.ap
  • 34,009
  • 10
  • 83
  • 174
  • Yes I have done the same...but I want to add new context menu ....the context menu will have only buttons side by side without any kind of text – Comp Droid May 23 '19 at 18:22