Skip to content

Commit 5f8386f

Browse files
justinmc0xZOne
authored andcommitted
Revert "Remove deprecated TextInputClient scribble method code" (flutter#39516)
Fixes the scribble feature (iPad handwriting input via Apple Pencil).
1 parent 88ff41d commit 5f8386f

2 files changed

Lines changed: 43 additions & 10 deletions

File tree

shell/platform/darwin/ios/framework/Source/FlutterEngine.mm

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -986,46 +986,69 @@ - (void)flutterTextInputView:(FlutterTextInputView*)textInputView
986986
#pragma mark - FlutterViewEngineDelegate
987987

988988
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView showToolbar:(int)client {
989-
[_scribbleChannel.get() invokeMethod:@"Scribble.showToolbar" arguments:@[ @(client) ]];
989+
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
990+
// the framework has finished transitioning to the Scribble channel.
991+
// https://github.com/flutter/flutter/pull/115296
992+
[_textInputChannel.get() invokeMethod:@"TextInputClient.showToolbar" arguments:@[ @(client) ]];
990993
}
991994

992995
- (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin
993996
focusElement:(UIScribbleElementIdentifier)elementIdentifier
994997
atPoint:(CGPoint)referencePoint
995998
result:(FlutterResult)callback {
996-
[_scribbleChannel.get()
997-
invokeMethod:@"Scribble.focusElement"
999+
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1000+
// the framework has finished transitioning to the Scribble channel.
1001+
// https://github.com/flutter/flutter/pull/115296
1002+
[_textInputChannel.get()
1003+
invokeMethod:@"TextInputClient.focusElement"
9981004
arguments:@[ elementIdentifier, @(referencePoint.x), @(referencePoint.y) ]
9991005
result:callback];
10001006
}
10011007

10021008
- (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin
10031009
requestElementsInRect:(CGRect)rect
10041010
result:(FlutterResult)callback {
1005-
[_scribbleChannel.get()
1006-
invokeMethod:@"Scribble.requestElementsInRect"
1011+
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1012+
// the framework has finished transitioning to the Scribble channel.
1013+
// https://github.com/flutter/flutter/pull/115296
1014+
[_textInputChannel.get()
1015+
invokeMethod:@"TextInputClient.requestElementsInRect"
10071016
arguments:@[ @(rect.origin.x), @(rect.origin.y), @(rect.size.width), @(rect.size.height) ]
10081017
result:callback];
10091018
}
10101019

10111020
- (void)flutterTextInputViewScribbleInteractionBegan:(FlutterTextInputView*)textInputView {
1012-
[_scribbleChannel.get() invokeMethod:@"Scribble.scribbleInteractionBegan" arguments:nil];
1021+
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1022+
// the framework has finished transitioning to the Scribble channel.
1023+
// https://github.com/flutter/flutter/pull/115296
1024+
[_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionBegan" arguments:nil];
10131025
}
10141026

10151027
- (void)flutterTextInputViewScribbleInteractionFinished:(FlutterTextInputView*)textInputView {
1016-
[_scribbleChannel.get() invokeMethod:@"Scribble.scribbleInteractionFinished" arguments:nil];
1028+
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1029+
// the framework has finished transitioning to the Scribble channel.
1030+
// https://github.com/flutter/flutter/pull/115296
1031+
[_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionFinished"
1032+
arguments:nil];
10171033
}
10181034

10191035
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
10201036
insertTextPlaceholderWithSize:(CGSize)size
10211037
withClient:(int)client {
1022-
[_scribbleChannel.get() invokeMethod:@"Scribble.insertTextPlaceholder"
1023-
arguments:@[ @(client), @(size.width), @(size.height) ]];
1038+
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1039+
// the framework has finished transitioning to the Scribble channel.
1040+
// https://github.com/flutter/flutter/pull/115296
1041+
[_textInputChannel.get() invokeMethod:@"TextInputClient.insertTextPlaceholder"
1042+
arguments:@[ @(client), @(size.width), @(size.height) ]];
10241043
}
10251044

10261045
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
10271046
removeTextPlaceholder:(int)client {
1028-
[_scribbleChannel.get() invokeMethod:@"Scribble.removeTextPlaceholder" arguments:@[ @(client) ]];
1047+
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
1048+
// the framework has finished transitioning to the Scribble channel.
1049+
// https://github.com/flutter/flutter/pull/115296
1050+
[_textInputChannel.get() invokeMethod:@"TextInputClient.removeTextPlaceholder"
1051+
arguments:@[ @(client) ]];
10291052
}
10301053

10311054
- (void)flutterTextInputViewDidResignFirstResponder:(FlutterTextInputView*)textInputView {

shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
@"TextInput.setEditableSizeAndTransform";
5151
static NSString* const kSetMarkedTextRectMethod = @"TextInput.setMarkedTextRect";
5252
static NSString* const kFinishAutofillContextMethod = @"TextInput.finishAutofillContext";
53+
// TODO(justinmc): Remove the TextInput method constant when the framework has
54+
// finished transitioning to using the Scribble channel.
55+
// https://github.com/flutter/flutter/pull/104128
56+
static NSString* const kDeprecatedSetSelectionRectsMethod = @"TextInput.setSelectionRects";
5357
static NSString* const kSetSelectionRectsMethod = @"Scribble.setSelectionRects";
5458
static NSString* const kStartLiveTextInputMethod = @"TextInput.startLiveTextInput";
5559

@@ -2107,6 +2111,12 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
21072111
} else if ([method isEqualToString:kFinishAutofillContextMethod]) {
21082112
[self triggerAutofillSave:[args boolValue]];
21092113
result(nil);
2114+
// TODO(justinmc): Remove the TextInput method constant when the framework has
2115+
// finished transitioning to using the Scribble channel.
2116+
// https://github.com/flutter/flutter/pull/104128
2117+
} else if ([method isEqualToString:kDeprecatedSetSelectionRectsMethod]) {
2118+
[self setSelectionRects:args];
2119+
result(nil);
21102120
} else if ([method isEqualToString:kSetSelectionRectsMethod]) {
21112121
[self setSelectionRects:args];
21122122
result(nil);

0 commit comments

Comments
 (0)