how to use the Accelerator keys?

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.

how to use the Accelerator keys?

Postby yanyuejie » Wed Aug 07, 2013 10:09 am

Accelerator keys works just when the cefclient demo run with --multi-threaded-message-loop and the window without browser. when CreateBrowser for the window, it dosnot work, why? how can make the accelerator keys works with the browser?
yanyuejie
Techie
 
Posts: 29
Joined: Fri Jul 26, 2013 4:43 am

Re: how to use the Accelerator keys?

Postby magreenblatt » Thu Aug 08, 2013 11:48 am

Accelerator keys can be handled by your application in CefKeyboardHandler::OnKeyEvent. The default implementation on Windows calls:
Code: Select all
  // Any unhandled keyboard/character messages are sent to DefWindowProc so that
  // shortcut keys work correctly.
  DefWindowProc(event.os_event.hwnd, event.os_event.message,
                event.os_event.wParam, event.os_event.lParam);

This likely doesn't work with multi-threaded because the window is created on a separate thread.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: how to use the Accelerator keys?

Postby ViswanathCt » Sun Dec 14, 2014 9:00 am

I had the same issue. But with a multi-threaded-message-loop.

The following code worked for me. Though I don't know, whether this is the right solution.
Code: Select all

bool client_handler::OnKeyEvent(
   CefRefPtr<CefBrowser> browser,
    const CefKeyEvent& event,
    CefEventHandle os_event) {
      
   // post any unhadled keys to the main window, so that hot keys could be captured
   PostMessage(hMainWindow, os_event->message, os_event->wParam, os_event->lParam);

   return false;
}

ViswanathCt
Newbie
 
Posts: 7
Joined: Tue Sep 09, 2014 10:28 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 80 guests