chromiumembedded/cef

`CefWindowDelegate::OnKeyEvent` is not triggered

Opened this issue · 0 comments

Describe the bug

While investigating the failure of ViewsWindowTest.WindowAccelerator, I noticed that the OnKeyEvent function is not triggered. This happens because CefWindowDelegate::OnKeyEvent is not being called as expected.

To Reproduce

I haven't tested on Linux or Windows, but I expect the issue to be reproducible there as well.
It does work on Windows using CefUnhandledKeyEventHandler:

class CefUnhandledKeyEventHandler : public ui::EventHandler {

Steps to reproduce the issue:

  1. Run the ViewsWindowTest.WindowAccelerator unit test:
./out/Debug_GN_arm64/ceftests.app/Contents/MacOS/ceftests --use-views --enable-chrome-runtime --gtest_filter=ViewsWindowTest.WindowAccelerator
  1. Observe that OnKeyEvent is never called.

Alternatively, you can:

  1. Run cefclient and set a breakpoint at ViewsWindow::OnKeyEvent:
    bool ViewsWindow::OnKeyEvent(CefRefPtr<CefWindow> window,
  2. Press any key.
  3. Notice that OnKeyEvent is not called.

Expected behavior

CefWindowDelegate::OnKeyEvent should be triggered whenever a key is pressed:

///
/// Called after all other controls in the window have had a chance to
/// handle the event. |event| contains information about the keyboard event.
/// Return true if the keyboard event was handled or false otherwise.
///
/*--cef()--*/
virtual bool OnKeyEvent(CefRefPtr<CefWindow> window,

Versions (please complete the following information):

  • OS: macOS 14.7
  • CEF Version: 129, 130