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
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 * Reset the text input plugin to prepare for a hot restart.
51 *
52 * This hides the software keyboard and text editing context menu.
53 */
54- (void)reset;
55
56/**
57 * The `UITextInput` implementation used to control text entry.
58 *
59 * This is used by `AccessibilityBridge` to forward interactions with iOS'
60 * accessibility system.
61 */
62- (UIView<UITextInput>*)textInputView;
63
64/**
65 * These are used by the UIIndirectScribbleInteractionDelegate methods to handle focusing on the
66 * correct element.
67 */
68- (void)setUpIndirectScribbleInteraction:(id<FlutterViewResponder>)viewResponder;
69- (void)resetViewResponder;
70- (BOOL)showEditMenu:(NSDictionary*)args API_AVAILABLE(ios(16.0));
71- (void)hideEditMenu API_AVAILABLE(ios(16.0));
72
73@end
74
75/** An indexed position in the buffer of a Flutter text editing widget. */
76@interface FlutterTextPosition : UITextPosition
77
78@property(nonatomic, readonly) NSUInteger index;
79@property(nonatomic, readonly) UITextStorageDirection affinity;
80
81+ (instancetype)positionWithIndex:(NSUInteger)index;
82+ (instancetype)positionWithIndex:(NSUInteger)index affinity:(UITextStorageDirection)affinity;
83- (instancetype)initWithIndex:(NSUInteger)index affinity:(UITextStorageDirection)affinity;
84
85@end
86
87/** A range of text in the buffer of a Flutter text editing widget. */
88@interface FlutterTextRange : UITextRange <NSCopying>
89
90@property(nonatomic, readonly) NSRange range;
91
92+ (instancetype)rangeWithNSRange:(NSRange)range;
93
94@end
95
96/** A tokenizer used by `FlutterTextInputView` to customize string parsing. */
97@interface FlutterTokenizer : UITextInputStringTokenizer
98@end
99
100@interface FlutterTextSelectionRect : UITextSelectionRect
101
102@property(nonatomic, assign) CGRect rect;
103@property(nonatomic) NSUInteger position;
104@property(nonatomic, assign) NSWritingDirection writingDirection;
105@property(nonatomic) BOOL containsStart;
106@property(nonatomic) BOOL containsEnd;
107@property(nonatomic) BOOL isVertical;
108
109+ (instancetype)selectionRectWithRectAndInfo:(CGRect)rect
110 position:(NSUInteger)position
111 writingDirection:(NSWritingDirection)writingDirection
112 containsStart:(BOOL)containsStart
113 containsEnd:(BOOL)containsEnd
114 isVertical:(BOOL)isVertical;
115
116+ (instancetype)selectionRectWithRect:(CGRect)rect position:(NSUInteger)position;
117
118+ (instancetype)selectionRectWithRect:(CGRect)rect
119 position:(NSUInteger)position
120 writingDirection:(NSWritingDirection)writingDirection;
121
122- (instancetype)initWithRectAndInfo:(CGRect)rect
123 position:(NSUInteger)position
124 writingDirection:(NSWritingDirection)writingDirection
125 containsStart:(BOOL)containsStart
126 containsEnd:(BOOL)containsEnd
127 isVertical:(BOOL)isVertical;
128
129- (instancetype)init NS_UNAVAILABLE;
130
131- (BOOL)isRTL;
132@end
133
134API_AVAILABLE(ios(13.0)) @interface FlutterTextPlaceholder : UITextPlaceholder
135@end
136
137#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
139#endif
140@interface FlutterTextInputView
141 : UIView <UITextInput, UIScribbleInteractionDelegate, UIEditMenuInteractionDelegate>
142
143// UITextInput
144@property(nonatomic, readonly) NSMutableString* text;
145@property(readwrite, copy) UITextRange* selectedTextRange;
146@property(nonatomic, strong) UITextRange* markedTextRange;
147@property(nonatomic, copy) NSDictionary* markedTextStyle;
148@property(nonatomic, weak) id<UITextInputDelegate> inputDelegate;
149@property(nonatomic, strong) NSMutableArray* pendingDeltas;
150
151// UITextInputTraits
152@property(nonatomic) UITextAutocapitalizationType autocapitalizationType;
153@property(nonatomic) UITextAutocorrectionType autocorrectionType;
154@property(nonatomic) UITextSpellCheckingType spellCheckingType;
156@property(nonatomic) UIKeyboardAppearance keyboardAppearance;
157@property(nonatomic) UIKeyboardType keyboardType;
158@property(nonatomic) UIReturnKeyType returnKeyType;
159@property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry;
160@property(nonatomic, getter=isEnableDeltaModel) BOOL enableDeltaModel;
161@property(nonatomic) UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0));
162@property(nonatomic) UITextSmartDashesType smartDashesType API_AVAILABLE(ios(11.0));
163@property(nonatomic, copy) UITextContentType textContentType API_AVAILABLE(ios(10.0));
164
165@property(nonatomic, weak) UIAccessibilityElement* backingTextInputAccessibilityObject;
166
167// Scribble Support
168@property(nonatomic, weak) id<FlutterViewResponder> viewResponder;
169@property(nonatomic) FlutterScribbleFocusStatus scribbleFocusStatus;
170@property(nonatomic, strong) NSArray<FlutterTextSelectionRect*>* selectionRects;
171
172@property(nonatomic, strong) UIEditMenuInteraction* editMenuInteraction API_AVAILABLE(ios(16.0));
175
176- (instancetype)init NS_UNAVAILABLE;
177+ (instancetype)new NS_UNAVAILABLE;
178- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
179- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
180- (instancetype)initWithOwner:(FlutterTextInputPlugin*)textInputPlugin NS_DESIGNATED_INITIALIZER;
181
182// TODO(louisehsu): These are being exposed to support Share in FlutterPlatformPlugin
183// Consider moving that feature into FlutterTextInputPlugin to avoid exposing extra methods
184- (CGRect)localRectFromFrameworkTransform:(CGRect)incomingRect;
185- (CGRect)caretRectForPosition:(UITextPosition*)position;
186@end
187
188@interface UIView (FindFirstResponder)
189@property(nonatomic, readonly) id flutterFirstResponder;
190@end
191
192#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
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
FlutterViewController * viewController
std::u16string text
int BOOL