Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FlutterTextInputPlugin.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTPLUGIN_H_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTPLUGIN_H_
7
8#import <UIKit/UIKit.h>
9
10#import "flutter/shell/platform/common/text_editing_delta.h"
11#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
12#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterIndirectScribbleDelegate.h"
13#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySecondaryResponder.h"
14#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h"
15#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h"
16
17typedef NS_ENUM(NSInteger, FlutterScribbleFocusStatus) {
18 // NOLINTBEGIN(readability-identifier-naming)
19 FlutterScribbleFocusStatusUnfocused,
20 FlutterScribbleFocusStatusFocusing,
21 FlutterScribbleFocusStatusFocused,
22 // NOLINTEND(readability-identifier-naming)
23};
24
25typedef NS_ENUM(NSInteger, FlutterScribbleInteractionStatus) {
26 // NOLINTBEGIN(readability-identifier-naming)
27 FlutterScribbleInteractionStatusNone,
28 FlutterScribbleInteractionStatusStarted,
29 FlutterScribbleInteractionStatusEnding,
30 // NOLINTEND(readability-identifier-naming)
31};
32
34 : NSObject <FlutterKeySecondaryResponder, UIIndirectScribbleInteractionDelegate>
35
36@property(nonatomic, weak) UIViewController* viewController;
37@property(nonatomic, weak) id<FlutterIndirectScribbleDelegate> indirectScribbleDelegate;
38@property(nonatomic, strong)
39 NSMutableDictionary<UIScribbleElementIdentifier, NSValue*>* scribbleElements;
40
41- (instancetype)init NS_UNAVAILABLE;
42+ (instancetype)new NS_UNAVAILABLE;
43
44- (instancetype)initWithDelegate:(id<FlutterTextInputDelegate>)textInputDelegate
45 NS_DESIGNATED_INITIALIZER;
46
47- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
48
49/**
50 * The `UITextInput` implementation used to control text entry.
51 *
52 * This is used by `AccessibilityBridge` to forward interactions with iOS'
53 * accessibility system.
54 */
55- (UIView<UITextInput>*)textInputView;
56
57/**
58 * These are used by the UIIndirectScribbleInteractionDelegate methods to handle focusing on the
59 * correct element.
60 */
61- (void)setUpIndirectScribbleInteraction:(id<FlutterViewResponder>)viewResponder;
62- (void)resetViewResponder;
63- (BOOL)showEditMenu:(NSDictionary*)args API_AVAILABLE(ios(16.0));
64- (void)hideEditMenu API_AVAILABLE(ios(16.0));
65
66@end
67
68/** An indexed position in the buffer of a Flutter text editing widget. */
69@interface FlutterTextPosition : UITextPosition
70
71@property(nonatomic, readonly) NSUInteger index;
72@property(nonatomic, readonly) UITextStorageDirection affinity;
73
74+ (instancetype)positionWithIndex:(NSUInteger)index;
75+ (instancetype)positionWithIndex:(NSUInteger)index affinity:(UITextStorageDirection)affinity;
76- (instancetype)initWithIndex:(NSUInteger)index affinity:(UITextStorageDirection)affinity;
77
78@end
79
80/** A range of text in the buffer of a Flutter text editing widget. */
81@interface FlutterTextRange : UITextRange <NSCopying>
82
83@property(nonatomic, readonly) NSRange range;
84
85+ (instancetype)rangeWithNSRange:(NSRange)range;
86
87@end
88
89/** A tokenizer used by `FlutterTextInputView` to customize string parsing. */
90@interface FlutterTokenizer : UITextInputStringTokenizer
91@end
92
93@interface FlutterTextSelectionRect : UITextSelectionRect
94
95@property(nonatomic, assign) CGRect rect;
96@property(nonatomic) NSUInteger position;
97@property(nonatomic, assign) NSWritingDirection writingDirection;
98@property(nonatomic) BOOL containsStart;
99@property(nonatomic) BOOL containsEnd;
100@property(nonatomic) BOOL isVertical;
101
102+ (instancetype)selectionRectWithRectAndInfo:(CGRect)rect
103 position:(NSUInteger)position
104 writingDirection:(NSWritingDirection)writingDirection
105 containsStart:(BOOL)containsStart
106 containsEnd:(BOOL)containsEnd
107 isVertical:(BOOL)isVertical;
108
109+ (instancetype)selectionRectWithRect:(CGRect)rect position:(NSUInteger)position;
110
111+ (instancetype)selectionRectWithRect:(CGRect)rect
112 position:(NSUInteger)position
113 writingDirection:(NSWritingDirection)writingDirection;
114
115- (instancetype)initWithRectAndInfo:(CGRect)rect
116 position:(NSUInteger)position
117 writingDirection:(NSWritingDirection)writingDirection
118 containsStart:(BOOL)containsStart
119 containsEnd:(BOOL)containsEnd
120 isVertical:(BOOL)isVertical;
121
122- (instancetype)init NS_UNAVAILABLE;
123
124- (BOOL)isRTL;
125@end
126
127API_AVAILABLE(ios(13.0)) @interface FlutterTextPlaceholder : UITextPlaceholder
128@end
129
130#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
132#endif
133@interface FlutterTextInputView
134 : UIView <UITextInput, UIScribbleInteractionDelegate, UIEditMenuInteractionDelegate>
135
136// UITextInput
137@property(nonatomic, readonly) NSMutableString* text;
138@property(readwrite, copy) UITextRange* selectedTextRange;
139@property(nonatomic, strong) UITextRange* markedTextRange;
140@property(nonatomic, copy) NSDictionary* markedTextStyle;
141@property(nonatomic, weak) id<UITextInputDelegate> inputDelegate;
142@property(nonatomic, strong) NSMutableArray* pendingDeltas;
143
144// UITextInputTraits
145@property(nonatomic) UITextAutocapitalizationType autocapitalizationType;
146@property(nonatomic) UITextAutocorrectionType autocorrectionType;
147@property(nonatomic) UITextSpellCheckingType spellCheckingType;
149@property(nonatomic) UIKeyboardAppearance keyboardAppearance;
150@property(nonatomic) UIKeyboardType keyboardType;
151@property(nonatomic) UIReturnKeyType returnKeyType;
152@property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry;
153@property(nonatomic, getter=isEnableDeltaModel) BOOL enableDeltaModel;
154@property(nonatomic) UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0));
155@property(nonatomic) UITextSmartDashesType smartDashesType API_AVAILABLE(ios(11.0));
156@property(nonatomic, copy) UITextContentType textContentType API_AVAILABLE(ios(10.0));
157
158@property(nonatomic, weak) UIAccessibilityElement* backingTextInputAccessibilityObject;
159
160// Scribble Support
161@property(nonatomic, weak) id<FlutterViewResponder> viewResponder;
162@property(nonatomic) FlutterScribbleFocusStatus scribbleFocusStatus;
163@property(nonatomic, strong) NSArray<FlutterTextSelectionRect*>* selectionRects;
164
165@property(nonatomic, strong) UIEditMenuInteraction* editMenuInteraction API_AVAILABLE(ios(16.0));
168
169- (instancetype)init NS_UNAVAILABLE;
170+ (instancetype)new NS_UNAVAILABLE;
171- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
172- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
173- (instancetype)initWithOwner:(FlutterTextInputPlugin*)textInputPlugin NS_DESIGNATED_INITIALIZER;
174
175// TODO(louisehsu): These are being exposed to support Share in FlutterPlatformPlugin
176// Consider moving that feature into FlutterTextInputPlugin to avoid exposing extra methods
177- (CGRect)localRectFromFrameworkTransform:(CGRect)incomingRect;
178- (CGRect)caretRectForPosition:(UITextPosition*)position;
179@end
180
181@interface UIView (FindFirstResponder)
182@property(nonatomic, readonly) id flutterFirstResponder;
183@end
184
185#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTPLUGIN_H_
void(^ FlutterResult)(id _Nullable result)
#define FLUTTER_DARWIN_EXPORT
UIView< UITextInput > * textInputView()
NSMutableDictionary< UIScribbleElementIdentifier, NSValue * > * scribbleElements
id< FlutterIndirectScribbleDelegate > indirectScribbleDelegate
UITextStorageDirection affinity
FlutterViewController * viewController
BOOL enablesReturnKeyAutomatically
UIAccessibilityElement * backingTextInputAccessibilityObject
NSDictionary * markedTextStyle
NSArray< FlutterTextSelectionRect * > * selectionRects
BOOL secureTextEntry
NSMutableArray * pendingDeltas
BOOL isScribbleAvailable
CGRect localRectFromFrameworkTransform
void resetScribbleInteractionStatusIfEnding
typedef NS_ENUM(NSInteger, FlutterScribbleFocusStatus)
UIKeyboardType keyboardType
UITextRange * markedTextRange
id< UITextInputDelegate > inputDelegate
instancetype init NS_UNAVAILABLE
UITextAutocorrectionType autocorrectionType
instancetype initWithFrame
FlutterScribbleFocusStatus scribbleFocusStatus
UITextSpellCheckingType spellCheckingType
API_AVAILABLE(ios(13.0)) @interface FlutterTextPlaceholder UITextRange * selectedTextRange
instancetype initWithOwner
id< FlutterViewResponder > viewResponder
UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0))
BOOL enableDeltaModel
instancetype initWithCoder
UITextAutocapitalizationType autocapitalizationType
UIReturnKeyType returnKeyType
CGRect caretRectForPosition
UIKeyboardAppearance keyboardAppearance
std::u16string text
Definition copy.py:1
int BOOL