Handling keyboard events

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.

Handling keyboard events

Postby rotolino » Fri Feb 11, 2011 7:53 am

I can't get a notification when the ESC key is pressed. I've tried setting a breakpoint in ClientHandler::HandleKeyEvent but I can't make it work.
I've set multi_threaded_message_loop = true; my browser loads a flash game.

Thanks in advance.
rotolino
Mentor
 
Posts: 68
Joined: Sun Dec 26, 2010 10:22 am

Re: Handling keyboard events

Postby magreenblatt » Fri Feb 11, 2011 5:49 pm

If the flash game has focus when the ESC key is pressed then there likely isn't any notification to the browser.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Handling keyboard events

Postby rotolino » Sat Feb 12, 2011 6:24 am

Does CEF handle those events in a separate thread? What's actually the UI thread I can read about on the comments in the source and how many thread are started?
Does CEF expose the thread it creates so I can use SetWindowsHookEx to install a handler?

Thanks!
rotolino
Mentor
 
Posts: 68
Joined: Sun Dec 26, 2010 10:22 am

Re: Handling keyboard events

Postby magreenblatt » Sat Feb 12, 2011 3:32 pm

From cef.h:
Code: Select all
// CEF maintains multiple internal threads that are used for handling different
// types of tasks. The UI thread creates the browser window and is used for all
// interaction with the WebKit rendering engine and V8 JavaScript engine (The
// UI thread will be the same as the main application thread if CefInitialize()
// is called with a CefSettings.multi_threaded_message_loop value of false.) The
// IO thread is used for handling schema and network requests. The FILE thread
// is used for the application cache and other miscellaneous activities.

Does CEF expose the thread it creates so I can use SetWindowsHookEx to install a handler?

You can post tasks to the various threads using the CefPostTask function. SetWindowsHookEx may work -- I haven't tried it myself.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Handling keyboard events

Postby rotolino » Sun Feb 13, 2011 4:27 am

Thank you, it works perfectly. If anyone is facing the same issue, just call:

hHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc2, NULL, GetCurrentThreadId());

in ClientHandler::HandleAfterCreated. This solution is Windows-specific and is only needed when multi_threaded_message_loop is true.

Regards.
rotolino
Mentor
 
Posts: 68
Joined: Sun Dec 26, 2010 10:22 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 59 guests