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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM