CEF禁止右键菜单

转载:http://www.cctry.com/thread-258549-1-1.html

转载:http://blog.sina.com.cn/s/blog_dad2c54101019cmo.html

转载:http://blog.csdn.net/qhh_qhh/article/details/50684443

cef如何禁用右键属性:

让自己的MyClientHandler来继承 CefContextMenuHandler这个抽象类,然对其下面的纯虚函数进行重写

1.获得事件处理器

virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() 
{
  return this;
}

2. 重写CefContextMenuHandler 的方法

void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
        CefRefPtr<CefFrame> frame,
        CefRefPtr<CefContextMenuParams> params,
        CefRefPtr<CefMenuModel> model) OVERRIDE;

实现

void MyClientHandler::OnBeforeContextMenu(
    CefRefPtr browser,
    CefRefPtr frame,
    CefRefPtr params,
    CefRefPtr model) {
  if ((params->GetTypeFlags() & (CM_TYPEFLAG_PAGE | CM_TYPEFLAG_FRAME)) != 0) {
    // Add a separator if the menu already has items.
    if (model->GetCount() > 0)
{
  model->Clear();
//model->AddSeparator();
}
  }
}
原文地址:https://www.cnblogs.com/chechen/p/6721462.html