Skip to content

Conversation

@dkwingsmt
Copy link
Contributor

This PR changes the logicalKey value of a RawKeyboardEvent that has a multi-char character.

Previously its logical key is a unicode key, whose 32-bit value part is the concatenation of the two characters. This is inproper because:

  • The resulting value is not a proper UniCode value. In fact, it will trigger an exception when being converted to keyLabel.
  • It incorrectly assumes that there won't be more than 2 characters, and every character can fit in the 16-bit BMP area.

With this PR, its logical key is its key code mapped to the macOS plane.

This fixes the macOS-channel part of #82673.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Nov 30, 2021
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@gspencergoog
Copy link
Contributor

I agree that the two character limit isn't right, but doesn't this disable all multi-char input, like emojis?

@dkwingsmt
Copy link
Contributor Author

dkwingsmt commented Dec 6, 2021

This change only affects the logical key's value (and consequently, the keyLabel of the logical key). It doesn't affect the event's character, or the ability to process this event.

And if that's the concern, yes, a multi-char emoji event (if that's a thing) will have a minted logical key. What else can we give for this event?

@gspencergoog
Copy link
Contributor

Got it. Makes sense.

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@dkwingsmt dkwingsmt merged commit 3af6b2f into flutter:master Dec 7, 2021
@dkwingsmt dkwingsmt deleted the fix-mac-raw-key-event-multi-char branch December 7, 2021 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants