Skip to content

Modifier key combinations don't send key up events to framework.  #44135

Closed
flutter-team-archive/engine
#13984

Description

@gspencergoog

Currently, the macOS shell seems to receive the key-up event for command sequences like "⌘-C" and "Shift-A" without producing a key up event in the framework for the letters, which is problematic on the framework side when someone wants to type, much less re-map it to something else, and it causes the framework to think that the non-modifier keys never went up, so they stick until someone presses the key again (e.g. if I press "⌘-C", the framework thinks that the "C" key is pressed until it gets pressed again).

Activity

  1. added
    engineflutter/engine related. See also e: labels.
    platform-macosBuilding on or for macOS specifically
    on Nov 4, 2019
  2. gspencergoog commented on Nov 4, 2019

    @gspencergoog
    ContributorAuthor
  3. gspencergoog commented on Nov 4, 2019

    @gspencergoog
    ContributorAuthor

    You'll likely need to apply #44130 before you can see what I mean (until it lands).

  4. shyndman commented on Nov 5, 2019

    @shyndman
    Contributor

    This might be worth surfacing again. I'm continuing to run this code with no issues.
    #38076 (comment)

  5. shyndman commented on Nov 5, 2019

    @shyndman
    Contributor

    The linked code was written to fix this issue precisely, although it might not be the best way to approach the problem since it requires a custom NSApplication. It looks like by the time the events reach the window they've undergone some interpretation by cocoa (which suppresses the keyUp).

    Maybe there's a way to hook into the raw event stream through a mechanism other than the NSApplication?

  6. gspencergoog commented on Nov 8, 2019

    @gspencergoog
    ContributorAuthor

    Thanks @shyndman, we'll definitely look at that method and evaluate it.

  7. changed the title [-]Command key combinations don't send key up events to framework. [/-] [+]Modifier key combinations don't send key up events to framework. [/+] on Nov 8, 2019
  8. franciscojma86 commented on Nov 21, 2019

    @franciscojma86
    Contributor

    Taking a look at this, it seems to be an OS limitation. It seems to only happen with command. While @shyndman suggestion does work, I worry that it might have an unexpected impact given that we would be overriding NSApplication. Another downside I see of that approach, is that it would have to be overriden from the runner app.

    @gspencergoog maybe this is something we can workaround on the framework side, to "free" the pressed key when command is released? FWIW if you release cmd before the key, keyUp is called

  9. franciscojma86 commented on Nov 21, 2019

    @franciscojma86
    Contributor

    My suggestion wouldn't actually work. Will keep looking into how we can get the raw event.

  10. shyndman commented on Nov 21, 2019

    @shyndman
    Contributor

    I have something to consider.

    Both Windows and macOS shortcuts work by evaluating a single keyboard key + a set of zero or more modifiers. The advantage of this approach is that a single keydown event describes whether or not to trigger the shortcut's action — no need to store comprehensive keyboard state.

    That said, I appreciate that in the current approach you can ask whether a key is down at any point. Useful. You can do this easily in Windows, too, but not in macOS without using lower-level APIs.

  11. franciscojma86 commented on Nov 22, 2019

    @franciscojma86
    Contributor

    @shyndman the behavior you suggest was implemented recently (using the modifies within the NSEvent of the pressed key) so that's indeed a good observation 😄. However, that doesn't solve the problem at hand since we don't even get the NSEvent from the key being released. I just posted a PR for review, using an approach similar to the one you suggested, but using a listener. Thanks for your suggestion!

  12. shyndman commented on Nov 22, 2019

    @shyndman
    Contributor

    🍾

  13. github-actions commented on Aug 25, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: desktopRunning on desktopengineflutter/engine related. See also e: labels.platform-macosBuilding on or for macOS specifically

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions