[iOS] Hardware keyboard text editing shortcuts (flutter/engine#28971)

* [iOS] Hardware keyboard text editing shortcuts

* Remove useless declarations
This commit is contained in:
Callum Moffat
2021-10-13 21:11:39 -04:00
committed by GitHub
parent f065dda7ab
commit 3329abdb4a
2 changed files with 48 additions and 0 deletions

View File

@@ -896,6 +896,30 @@ static FlutterAutofillType autofillTypeOf(NSDictionary* configuration) {
return _textInputClient != 0;
}
#pragma mark - UIResponderStandardEditActions Overrides
- (void)cut:(id)sender {
[UIPasteboard generalPasteboard].string = [self textInRange:_selectedTextRange];
[self replaceRange:_selectedTextRange withText:@""];
}
- (void)copy:(id)sender {
[UIPasteboard generalPasteboard].string = [self textInRange:_selectedTextRange];
}
- (void)paste:(id)sender {
[self insertText:[UIPasteboard generalPasteboard].string];
}
- (void)delete:(id)sender {
[self replaceRange:_selectedTextRange withText:@""];
}
- (void)selectAll:(id)sender {
[self setSelectedTextRange:[self textRangeFromPosition:[self beginningOfDocument]
toPosition:[self endOfDocument]]];
}
#pragma mark - UITextInput Overrides
- (id<UITextInputTokenizer>)tokenizer {

View File

@@ -247,6 +247,30 @@ FLUTTER_ASSERT_ARC
XCTAssertEqual(substring.length, 0ul);
}
- (void)testStandardEditActions {
NSDictionary* config = self.mutableTemplateCopy;
[self setClientId:123 configuration:config];
NSArray<FlutterTextInputView*>* inputFields = self.installedInputViews;
FlutterTextInputView* inputView = inputFields[0];
[inputView insertText:@"aaaa"];
[inputView selectAll:nil];
[inputView cut:nil];
[inputView insertText:@"bbbb"];
[inputView paste:nil];
[inputView selectAll:nil];
[inputView copy:nil];
[inputView paste:nil];
[inputView selectAll:nil];
[inputView delete:nil];
[inputView paste:nil];
[inputView paste:nil];
UITextRange* range = [FlutterTextRange rangeWithNSRange:NSMakeRange(0, 30)];
NSString* substring = [inputView textInRange:range];
XCTAssertEqualObjects(substring, @"bbbbaaaabbbbaaaa");
}
- (void)testNoZombies {
// Regression test for https://github.com/flutter/flutter/issues/62501.
FlutterSecureTextInputView* passwordView = [[FlutterSecureTextInputView alloc] init];