Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@justinmc
Copy link
Contributor

@justinmc justinmc commented Feb 23, 2024

The cut/copy/paste buttons above the keyboard on iPad were always greyed out, and this PR enables them to work with the current text input as normal.

Native Reminders app on iPad allows cut/copy/paste Flutter app on iPad greys out cut/copy/paste Flutter after this PR
Screenshot 2024-02-23 at 10 57 08 AM Screenshot 2024-02-23 at 10 56 24 AM Screenshot 2024-02-23 at 12 25 07 PM

Fixes flutter/flutter#102940

// When scribble is available, the FlutterTextInputView will display the native toolbar unless
// these text editing actions are disabled.
if ([self isScribbleAvailable] && sender == NULL) {
return NO;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fbcouch Any idea if this is still doing anything important?

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be worth checking on iPadOS 16 vs 17 just to be sure (I have an iPad that's only on 16, so I can test that one once this is built, if needed), but it may be that other things in the engine or OS have changed to prevent the native toolbar from showing up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I think I have an iPad with 17, I'll try it out tonight and post back.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think i looked into this but forgot - in what other cases will sender be nil too? during scribble it seems?

i vaguely remember when you enter memoji sender is nil, but could be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure, but yeah it looks like during Scribble. Flutter doesn't support selecting a memoji out of the box does it?

I forgot to link my response here (#50923 (comment)), but I did try this out on a physical iOS 17 iPad and it seemed to work fine. I tried all of the Scribble features I could think of, plus normal soft keyboard text editing, including the text selection toolbar.

Copy link
Contributor

Choose a reason for hiding this comment

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

i vaguely remember when you enter memoji sender is nil, but could be wrong.

I think i remember it wrongly. memoji has nothing to do with this line.

Flutter doesn't support selecting a memoji out of the box does it?

Yes, but memoji is part of the keyboard that we don't control. So what we did was to make it a no-op when user choose their memoji. This is done with the pasteboard.hasStrings check below.

@chinmaygarde
Copy link
Member

@justinmc Are we making progress on this?

@justinmc
Copy link
Contributor Author

justinmc commented Mar 7, 2024

Sorry, meant to try this at home and forgot about it. Making a note to do so tonight.

@justinmc
Copy link
Contributor Author

justinmc commented Mar 8, 2024

I've tried this out on a physical device and Scribble works fine. I'll take a look at the failing test, though.

@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 "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

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.

return pasteboard.hasStrings;
}
// Forbid pasting images, memojis, or other non-string content.
return [UIPasteboard generalPasteboard].string != nil;
Copy link
Contributor Author

@justinmc justinmc Mar 8, 2024

Choose a reason for hiding this comment

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

Accessing the pasteboard string here was causing an unnecessary paste notification to show to the user when the keyboard was brought up. Using hasStrings instead fixes it. FYI @hellohuanlin.

@justinmc justinmc requested a review from hellohuanlin March 8, 2024 18:48
}
if (action == @selector(paste:)) {
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
if (@available(iOS 10, *)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

iirc the minimum is already ios 11?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to this page we don't support 11 and under, you're right! I'll remove this.

@hellohuanlin
Copy link
Contributor

hellohuanlin commented Mar 8, 2024

@moffatman may know more about why we had this check in the first place. could you help to take a look?

@moffatman
Copy link
Contributor

I don't know why the canPerformAction check is there. last time i looked in this file was to add the paste: handlers. And that was before canPerformAction was added

}

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
// When scribble is available, the FlutterTextInputView will display the native toolbar unless
Copy link
Contributor

@hellohuanlin hellohuanlin Mar 8, 2024

Choose a reason for hiding this comment

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

what is the "native toolbar"? i assume it's not the edit menu?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my memory I think the system context menu (AKA text selection toolbar) was showing up? Maybe @fbcouch can confirm.

I did not see that happen just now when I tested Scribble on an iPad running iOS 17.

@justinmc justinmc merged commit 831279e into flutter:main Mar 8, 2024
@justinmc justinmc deleted the ipad-cut-copy-paste branch March 8, 2024 21:30
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 8, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 9, 2024
…144849)

flutter/engine@e099277...953927e

2024-03-08 [email protected] Revert test if changes to golden tests (flutter/engine#51291)
2024-03-08 [email protected] iPad keyboard cut/copy/paste buttons (flutter/engine#50923)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iPadOS] Keyboard shortcut actions are disabled

5 participants