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