Skip to content

Unexpected behavior when using KeyEventDispatcher interface #350

Open
@magreenblatt

Description

@magreenblatt

Original report by Dave Tarkowski (Bitbucket: David Tarkowski).


When I add a KeyEventDispatcherhandler, the behavior is different between Windows and Mac, specifically, I think that the Mac version is wrong.

I’ve attached a set of files which modify the detailed test. The changes include the following:

  1. In MainFrame.java, add a KeyEventDispatcher which does the following:

    1. Print a message
    2. Sleep for 100ms
    3. Print out another message
    4. Return true to indicate that any further key event processing should be cancelled.
  2. In handler/KeyboardHandler.java add an onPreKeyEvent handler which prints a message showing when the onPreKeyEvent is fired.

When running that code I observe the following:

  • On Windows, the KeyEventDispatcher is never fired when the focus is in the browser window. If it is in a pure Java component, like the address bar, it is fired and behaves as normal.
  • On Mac, when the focus is in the browser, the KeyEventDispatcher is not fired for normal key events, but it is for events that use modifiers such as CTRL and CMD, for example, Ctrl+Shift+a.
  • On Mac, while the KeyEventDispatcher is sleeping, the onPreKeyEvent is fired. If the KeyEventDispatcher is being fired, it should be allowed to process the key event before being passed on to any other components.

I’m not sure if the Windows behavior is correct, but I am okay with it.

The big problem on the Mac is that the KeyEventDispatcher is not allowed to swallow the processing when it is fired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions