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

[iOS] Hardware keyboard text editing shortcuts #28971

Merged
merged 2 commits into from
Oct 14, 2021

Conversation

moffatman
Copy link
Contributor

@moffatman moffatman commented Sep 30, 2021

Implementing these methods enables the following keyboard shortcuts:

  • Command-A to select all
  • Command-X to cut
  • Command-C to copy
  • Command-V to paste

I am not completely sure about the delete method, but it's another part of the specification that could be easily implemented. I think it will likely enable Edit->Delete when running Flutter iOS on Apple Silicon Macs, but I don't have one to test it on.

I could not find a way to get the Command-Left / Command-Right shortcuts for Beginning of line / End of line to work.

Should fix flutter/flutter#73950, flutter/flutter#70104, and flutter/flutter#68514.

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] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

The code looks ok, but I don't quite get why this change solves all three issues. Can you give a brief explanation?

@moffatman
Copy link
Contributor Author

The code looks ok, but I don't quite get why this change solves all three issues. Can you give a brief explanation?

UIKit checks if the current responder can handle these selectors in order to enable the text editing shortcuts for cut/copy/paste. This includes the command-c, command-v... keyboard shortcuts, as well as the buttons above the software keyboard. It's not possible to test for that functionality, since XCTest has no support to trigger keyboard shortcuts, it can only type normal text. But I found after this change that the hardware keyboard editing shortcuts work.

@dkwingsmt
Copy link
Contributor

Thanks for the explanation. Go ahead and merge when you feel like.

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

Successfully merging this pull request may close these issues.

[iOS] TextField do not response to keyboard shortcuts like CMD+c when using bluetooth keyboard
3 participants