Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior when using KeyEventDispatcher interface #350

Open
magreenblatt opened this issue Sep 11, 2019 · 0 comments
Open

Unexpected behavior when using KeyEventDispatcher interface #350

magreenblatt opened this issue Sep 11, 2019 · 0 comments
Labels
bug Bug report

Comments

@magreenblatt
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report
Projects
None yet
Development

No branches or pull requests

1 participant