Question about disabling right-click for cefsimple in CEF3

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Question about disabling right-click for cefsimple in CEF3

Postby aabragan » Wed Apr 09, 2014 3:47 pm

I am trying to embed a chrome browser in an application and would like to use functionality similar to that demonstrated in cefsimple project. I am running into one small problem that I wanted you as you about. In the CefClient, I was able to disable and completely remove the right-click functionality but I am not able to disable and remove that functionality in the simple version of the client. I tried to add public CefContextMenuHandler as a class that SimpleHandler inherits from and overrode the methods in the class, but I think there is something I am missing with the browserhost. I know that the browser is embedded in the browserhost and the browserhost proxies request to the browser. Could you tell me what I am missing.? I can send you the modified version of the solution that I have if you want to see what I am doing. Sorry for the bother. I would really appreciate your help. Thanks in advance!

I am using the google project code.
https://code.google.com/p/chromiumembedded/

I went to http://cefbuilds.com/ and downloaded the following cef_binary_3.1846.1637_windows64

I added a new class that SimpleHandler inherited from (CefContextMenuHandler)
Code: Select all
class SimpleHandler : public CefClient,
                 public CefContextMenuHandler,
                      public CefDisplayHandler,
                      public CefLifeSpanHandler,
                      public CefLoadHandler {


Then I overrode the 2 virtual methods for testing purposes (but they don't work)
Code: Select all

void SimpleHandler::OnBeforeContextMenu(
   CefRefPtr<CefBrowser> browser,
   CefRefPtr<CefFrame> frame,
   CefRefPtr<CefContextMenuParams> params,
   CefRefPtr<CefMenuModel> model) {
      REQUIRE_UI_THREAD();

      model->Clear();
}

bool SimpleHandler::OnContextMenuCommand(
   CefRefPtr<CefBrowser> browser,
   CefRefPtr<CefFrame> frame,
   CefRefPtr<CefContextMenuParams> params,
   int command_id,
   EventFlags event_flags) {
      REQUIRE_UI_THREAD();
      
      MessageBox(browser->GetHost()->GetWindowHandle(), L"The requested action is not supported", L"Unsupported Action", MB_OK | MB_ICONINFORMATION);
      return false;
}
aabragan
Newbie
 
Posts: 2
Joined: Wed Apr 09, 2014 3:39 pm

Re: Question about disabling right-click for cefsimple in CE

Postby magreenblatt » Wed Apr 09, 2014 3:54 pm

Did you implement CefClient::GetContextMenuHandler?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Question about disabling right-click for cefsimple in CE

Postby aabragan » Wed Apr 09, 2014 6:48 pm

That was it. Thanks for the assist! You ROCK! #likeaboss :D
aabragan
Newbie
 
Posts: 2
Joined: Wed Apr 09, 2014 3:39 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 108 guests