-
Notifications
You must be signed in to change notification settings - Fork 279
How to hide the right click menu? #18
Comments
Chromely is fully configurable. Almost all features can be configured. Please be familiar with Configuration wiki. This is where the features are added or removed. In this case you want to configure a custom handler. Please see wiki @ How to Add Custom Handlers So to give you a guide .. in Program.cs file you will need to add the RegisterCustomHandler method to the fluent configuration. You can register as many valid handlers allowed either for CefSharp or CefGlue. Note that if none is registered it will use the default. ChromelyConfiguration config = ChromelyConfiguration
.Create()
.....
.RegisterCustomHandler(CefHandlerKey.ContextMenuHandler, typeof(CustomContextMenuHandler));
.... So assuming this is CefGlue app, CustomContextMenuHandler is a custom handler that must inherit from CefContextMenuHandler see the default So the custom class can be like: public class CustomContextMenuHandler : CefContextMenuHandler
{
protected override void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model)
{
// To disable the menu then call clear
model.Clear();
// Removing existing menu item
// Remove "View Source" option
model.Remove((int)CefMenuId.ViewSource);
}
protected override bool RunContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams parameters, CefMenuModel model, CefRunContextMenuCallback callback)
{
return false;
}
protected override bool OnContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams state, int commandId, CefEventFlags eventFlags)
{
return false;
}
protected override void OnContextMenuDismissed(CefBrowser browser, CefFrame frame)
{
}
private class DevToolsWebClient : CefClient
{
}
} This will remove those commands. You can add more commands as you like. I may have to reconsider making this the default and create a separate handler for debugging purpose. I will look into that. Please let me know if you have more questions. |
thanks mattkol, I used CefSharp and implement handler class like below to hide the menu, it works well, thanks a lot for your help. One more question, I find CefSharp based on version 63, and CefGlue based on 65, why CefSharp used the lower version and not up to date? public class CustomContextMenuHandler : IContextMenuHandler
} Thanks, |
Hi Jack, Good to know the issue is fixed. On CefSharp/CefGlue version, since Chromely is a consumer of these products, I think it will be more appropriate to release Chromely based on their version final releases. CefSharp v65 is pre-release, As soon as it is a final release, Chromely will be updated. CefGlue current release is v66. This will be done soon. Thanks. |
Got it, thanks a lot and good job! |
Appreciated! Thanks. |
Hi,
It's not a issue, maybe it's feature reqiure, how to hide the right click menu? is there any option to do that? I don't want user click the right menu the "Show DevTools" and "Close DevTools" to review source code.
Thanks,
Jack
The text was updated successfully, but these errors were encountered: