Disabling the right-click menu is actually very easy. The main is to implement an interface Imenuhandler, this interface has a Onbeforecontextmenu method, we are here to return a false, the right-click menu disappears.
ClassMenuhandler:imenuhandler {public bool Onbeforecontextmenu (Iwebbrowser Browser, Icontextmenuparams parameters) { return false; } }
It is OK to assign this instance of the image to the Menuhandler property of the Chromiumwebbrowser object.
New Menuhandler ();
The above method applies to older versions of Cefsharp
43.00 start,Imenuhandler has been renamed, directly copy the above code does not exist
Asked the master, his own thinking of the original changed into a Icontextmenuhandler
And this interface below already have a few control menu method, because I get started C # is not deep, only according to the VS prompt, said interface needs to be rewritten,
The method is rewritten as prompted, but the default is throw new NotImplementedException ();
Obviously this is not possible, these three methods from the literal understanding, Control menu appearance should be Onbeforecontextmenu, there are 2, one is bool, one does not know
Look carefully, the second does not need to return the value, there is a imenumodel model, inadvertently seen on the Internet master directly call CEF with Cefsharp a method model. Clear ();
Write down the following code, and also ask the master to see the following correction
Internal class Menuhandler:icontextmenuhandler
{
public bool Onbeforecontextmenu (iwebbrowser browser,ibrowser ibrower,iframe iframe,icontextmenuparams Icontextmenuparams,imenumodel Imenumodel)
{
return false;
}
public bool Oncontextmenucommand (iwebbrowser BrowserControl, Ibrowser browser, IFrame frame, icontextmenuparams Parameters, Cefmenucommand commandId, Cefeventflags eventflags)
{
return false;
throw new NotImplementedException ();
}
public void oncontextmenudismissed (Iwebbrowser browsercontrol, Ibrowser Browser, IFrame frame)
{
throw new NotImplementedException ();
}
void Icontextmenuhandler.onbeforecontextmenu (Iwebbrowser browsercontrol, Ibrowser browser, IFrame frame, Icontextmenuparams parameters, Imenumodel model)
{
Model. Clear ();
}
}
The new "Cefsharp" disables the right-click menu 43.00+