Where/how are keyboard events handled in CEF?

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.

Where/how are keyboard events handled in CEF?

Postby coltcabana » Tue Feb 19, 2019 5:27 pm

When I start a browser window using cefsimple on Windows, where are the keyboard events handled? Say I press a key when focused on the window. I'm assuming there's a window somewhere getting the WM_KEY* messages. Is this that window - https://bitbucket.org/chromiumembedded/cef/src/6bfb5ab33b68aadd13bba055d195c2f6aa9a81d6/libcef/browser/native/browser_platform_delegate_native_win.cc?at=master#browser_platform_delegate_native_win.cc-629? If yes, I don't see it handling any WM_KEY* messages. If not, what window would that be? I tried reading through the CEF/chromium sources but got lost between all the WNDPROCs and class names which I don't have enough background on to make sense of.

I'm asking this because we have an application where the CEF window will be transparent and parented by a transparent window as well. Another window in the background (unrelated to CEF or its parent) will get the key presses which we then want to feed into CEF. Is CEF's SendKeyEvent the right way to do this? Do such key events need to be posted to CEF from a specific thread? I was looking into how CEF/Chromium handles keyboard events internally in case SendKeyEvent is not the right approach and we need to emulate what Chromium does internally.

Thanks in advance, and sorry if some of these questions are not valid/don't make sense.
coltcabana
Newbie
 
Posts: 1
Joined: Tue Feb 19, 2019 4:32 pm

Re: Where/how are keyboard events handled in CEF?

Postby Czarek » Thu Feb 21, 2019 10:16 am

There is CefKeyboardHandler with which you can intercept key events. If it's about sending key events then use SendKeyEvent, see doc comments in that file. Chromium/CEF doesn't invent new concepts here, so do what the platform expects. You can find example usage in cefclient OSR example.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 33 guests