iPad keyboard cut/copy/paste buttons (flutter/engine#50923)

The cut/copy/paste buttons above the keyboard on iPad were previously always greyed out, but now they work.
This commit is contained in:
Justin McCandless
2024-03-08 13:30:50 -08:00
committed by GitHub
parent a4c787e072
commit 3a07dc741a
2 changed files with 4 additions and 9 deletions

View File

@@ -1145,14 +1145,9 @@ static BOOL IsSelectionRectBoundaryCloserToPoint(CGPoint point,
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
// 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;
}
if (action == @selector(paste:)) {
// Forbid pasting images, memojis, or other non-string content.
return [UIPasteboard generalPasteboard].string != nil;
return [UIPasteboard generalPasteboard].hasStrings;
}
return [super canPerformAction:action withSender:sender];

View File

@@ -1299,15 +1299,15 @@ FLUTTER_ASSERT_ARC
[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"]);
}
}