Revert "Remove deprecated TextInputClient scribble method code" (flutter/engine#39516)

Fixes the scribble feature (iPad handwriting input via Apple Pencil).
This commit is contained in:
Justin McCandless
2023-02-10 11:48:43 -08:00
committed by GitHub
parent 65625a017b
commit 2e0bee3e44
2 changed files with 43 additions and 10 deletions

View File

@@ -986,15 +986,21 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
#pragma mark - FlutterViewEngineDelegate
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView showToolbar:(int)client {
[_scribbleChannel.get() invokeMethod:@"Scribble.showToolbar" arguments:@[ @(client) ]];
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
// the framework has finished transitioning to the Scribble channel.
// https://github.com/flutter/flutter/pull/115296
[_textInputChannel.get() invokeMethod:@"TextInputClient.showToolbar" arguments:@[ @(client) ]];
}
- (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin
focusElement:(UIScribbleElementIdentifier)elementIdentifier
atPoint:(CGPoint)referencePoint
result:(FlutterResult)callback {
[_scribbleChannel.get()
invokeMethod:@"Scribble.focusElement"
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
// the framework has finished transitioning to the Scribble channel.
// https://github.com/flutter/flutter/pull/115296
[_textInputChannel.get()
invokeMethod:@"TextInputClient.focusElement"
arguments:@[ elementIdentifier, @(referencePoint.x), @(referencePoint.y) ]
result:callback];
}
@@ -1002,30 +1008,47 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
- (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin
requestElementsInRect:(CGRect)rect
result:(FlutterResult)callback {
[_scribbleChannel.get()
invokeMethod:@"Scribble.requestElementsInRect"
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
// the framework has finished transitioning to the Scribble channel.
// https://github.com/flutter/flutter/pull/115296
[_textInputChannel.get()
invokeMethod:@"TextInputClient.requestElementsInRect"
arguments:@[ @(rect.origin.x), @(rect.origin.y), @(rect.size.width), @(rect.size.height) ]
result:callback];
}
- (void)flutterTextInputViewScribbleInteractionBegan:(FlutterTextInputView*)textInputView {
[_scribbleChannel.get() invokeMethod:@"Scribble.scribbleInteractionBegan" arguments:nil];
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
// the framework has finished transitioning to the Scribble channel.
// https://github.com/flutter/flutter/pull/115296
[_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionBegan" arguments:nil];
}
- (void)flutterTextInputViewScribbleInteractionFinished:(FlutterTextInputView*)textInputView {
[_scribbleChannel.get() invokeMethod:@"Scribble.scribbleInteractionFinished" arguments:nil];
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
// the framework has finished transitioning to the Scribble channel.
// https://github.com/flutter/flutter/pull/115296
[_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionFinished"
arguments:nil];
}
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
insertTextPlaceholderWithSize:(CGSize)size
withClient:(int)client {
[_scribbleChannel.get() invokeMethod:@"Scribble.insertTextPlaceholder"
arguments:@[ @(client), @(size.width), @(size.height) ]];
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
// the framework has finished transitioning to the Scribble channel.
// https://github.com/flutter/flutter/pull/115296
[_textInputChannel.get() invokeMethod:@"TextInputClient.insertTextPlaceholder"
arguments:@[ @(client), @(size.width), @(size.height) ]];
}
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
removeTextPlaceholder:(int)client {
[_scribbleChannel.get() invokeMethod:@"Scribble.removeTextPlaceholder" arguments:@[ @(client) ]];
// TODO(justinmc): Switch from the TextInputClient to Scribble channel when
// the framework has finished transitioning to the Scribble channel.
// https://github.com/flutter/flutter/pull/115296
[_textInputChannel.get() invokeMethod:@"TextInputClient.removeTextPlaceholder"
arguments:@[ @(client) ]];
}
- (void)flutterTextInputViewDidResignFirstResponder:(FlutterTextInputView*)textInputView {

View File

@@ -50,6 +50,10 @@ static NSString* const kSetEditableSizeAndTransformMethod =
@"TextInput.setEditableSizeAndTransform";
static NSString* const kSetMarkedTextRectMethod = @"TextInput.setMarkedTextRect";
static NSString* const kFinishAutofillContextMethod = @"TextInput.finishAutofillContext";
// TODO(justinmc): Remove the TextInput method constant when the framework has
// finished transitioning to using the Scribble channel.
// https://github.com/flutter/flutter/pull/104128
static NSString* const kDeprecatedSetSelectionRectsMethod = @"TextInput.setSelectionRects";
static NSString* const kSetSelectionRectsMethod = @"Scribble.setSelectionRects";
static NSString* const kStartLiveTextInputMethod = @"TextInput.startLiveTextInput";
@@ -2107,6 +2111,12 @@ static BOOL IsSelectionRectCloserToPoint(CGPoint point,
} else if ([method isEqualToString:kFinishAutofillContextMethod]) {
[self triggerAutofillSave:[args boolValue]];
result(nil);
// TODO(justinmc): Remove the TextInput method constant when the framework has
// finished transitioning to using the Scribble channel.
// https://github.com/flutter/flutter/pull/104128
} else if ([method isEqualToString:kDeprecatedSetSelectionRectsMethod]) {
[self setSelectionRects:args];
result(nil);
} else if ([method isEqualToString:kSetSelectionRectsMethod]) {
[self setSelectionRects:args];
result(nil);