Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1145,14 +1145,9 @@ - (BOOL)resignFirstResponder {
}

- (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.

// 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.

}
if (action == @selector(paste:)) {
// 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.

return [UIPasteboard generalPasteboard].hasStrings;
}

return [super canPerformAction:action withSender:sender];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,15 +1299,15 @@ - (void)testCanCopyPasteWithScribbleEnabled {
[mockInputView insertText:@"aaaa"];
[mockInputView selectAll:nil];

XCTAssertFalse([mockInputView canPerformAction:@selector(copy:) withSender:NULL]);
XCTAssertTrue([mockInputView canPerformAction:@selector(copy:) withSender:NULL]);
XCTAssertTrue([mockInputView canPerformAction:@selector(copy:) withSender:@"sender"]);
XCTAssertFalse([mockInputView canPerformAction:@selector(paste:) withSender:NULL]);
XCTAssertFalse([mockInputView canPerformAction:@selector(paste:) withSender:@"sender"]);

[mockInputView copy:NULL];
XCTAssertFalse([mockInputView canPerformAction:@selector(copy:) withSender:NULL]);
XCTAssertTrue([mockInputView canPerformAction:@selector(copy:) withSender:NULL]);
XCTAssertTrue([mockInputView canPerformAction:@selector(copy:) withSender:@"sender"]);
XCTAssertFalse([mockInputView canPerformAction:@selector(paste:) withSender:NULL]);
XCTAssertTrue([mockInputView canPerformAction:@selector(paste:) withSender:NULL]);
XCTAssertTrue([mockInputView canPerformAction:@selector(paste:) withSender:@"sender"]);
}
}
Expand Down