Adds force cursor support (flutter/engine#6945)

* engine force cursor support
This commit is contained in:
jslavitz
2018-12-13 18:45:38 -08:00
committed by GitHub
parent 880010c54d
commit 0abb1665f5
3 changed files with 46 additions and 0 deletions

View File

@@ -373,6 +373,25 @@
arguments:@[ @(client), state ]];
}
- (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state
withClient:(int)client
withPosition:(NSDictionary*)position {
NSString* stateString;
switch (state) {
case FlutterFloatingCursorDragStateStart:
stateString = @"FloatingCursorDragState.start";
break;
case FlutterFloatingCursorDragStateUpdate:
stateString = @"FloatingCursorDragState.update";
break;
case FlutterFloatingCursorDragStateEnd:
stateString = @"FloatingCursorDragState.end";
break;
}
[_textInputChannel.get() invokeMethod:@"TextInputClient.updateFloatingCursor"
arguments:@[ @(client), stateString, position ]];
}
- (void)performAction:(FlutterTextInputAction)action withClient:(int)client {
NSString* actionString;
switch (action) {

View File

@@ -21,10 +21,19 @@ typedef NS_ENUM(NSInteger, FlutterTextInputAction) {
FlutterTextInputActionNewline,
};
typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) {
FlutterFloatingCursorDragStateStart,
FlutterFloatingCursorDragStateUpdate,
FlutterFloatingCursorDragStateEnd,
};
@protocol FlutterTextInputDelegate <NSObject>
- (void)updateEditingClient:(int)client withState:(NSDictionary*)state;
- (void)performAction:(FlutterTextInputAction)action withClient:(int)client;
- (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state
withClient:(int)client
withPosition:(NSDictionary*)point;
@end

View File

@@ -566,6 +566,24 @@ static UIReturnKeyType ToUIReturnKeyType(NSString* inputType) {
return [FlutterTextRange rangeWithNSRange:[self rangeForCharacterAtIndex:currentIndex]];
}
- (void)beginFloatingCursorAtPoint:(CGPoint)point {
[_textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateStart
withClient:_textInputClient
withPosition:@{@"X" : @(point.x), @"Y" : @(point.y)}];
}
- (void)updateFloatingCursorAtPoint:(CGPoint)point {
[_textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateUpdate
withClient:_textInputClient
withPosition:@{@"X" : @(point.x), @"Y" : @(point.y)}];
}
- (void)endFloatingCursor {
[_textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateEnd
withClient:_textInputClient
withPosition:@{@"X" : @(0), @"Y" : @(0)}];
}
#pragma mark - UIKeyInput Overrides
- (void)updateEditingState {