| Flutter macOS Embedder |

Classes | Functions | Variables
FlutterTextInputPlugin.mm File Reference
`#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.h"`
`#import <Foundation/Foundation.h>`
`#import <objc/message.h>`
`#include <algorithm>`
`#include <memory>`
`#include "flutter/fml/platform/darwin/string_range_sanitization.h"`
`#include "flutter/shell/platform/common/text_editing_delta.h"`
`#include "flutter/shell/platform/common/text_input_model.h"`
`#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"`
`#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputSemanticsObject.h"`
`#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"`

Go to the source code of this file.

## Classes
category | NSEvent(KeyEquivalentMarker)

## Functions
typedef | NS_ENUM (NSUInteger, FlutterTextAffinity)
static flutter::TextRange | RangeFromBaseExtent (NSNumber *base, NSNumber *extent, const flutter::TextRange &range)
static NSString * | GetAutofillHint (NSDictionary *autofill)
static NSTextContentType | GetTextContentType (NSDictionary *configuration) API_AVAILABLE(macos(11.0))
static BOOL | EnableAutocompleteForTextInputConfiguration (NSDictionary *configuration)
static BOOL | EnableAutocomplete (NSDictionary *configuration)

## Variables
static NSString *const | kTextInputChannel = @"@"flutter/textinput"
static NSString *const | kSetClientMethod = @"@"TextInput.setClient"
static NSString *const | kShowMethod = @"@"TextInput.show"
static NSString *const | kHideMethod = @"@"TextInput.hide"
static NSString *const | kClearClientMethod = @"@"TextInput.clearClient"
static NSString *const | kSetEditingStateMethod = @"@"TextInput.setEditingState"
static NSString *const | kSetEditableSizeAndTransform = @"@"TextInput.setEditableSizeAndTransform"
static NSString *const | kSetCaretRect = @"@"TextInput.setCaretRect"
static NSString *const | kUpdateEditStateResponseMethod = @"@"TextInputClient.updateEditingState"
static NSString *const | kUpdateEditStateWithDeltasResponseMethod
static NSString *const | kPerformAction = @"@"TextInputClient.performAction"
static NSString *const | kPerformSelectors = @"@"TextInputClient.performSelectors"
static NSString *const | kMultilineInputType = @"@"TextInputType.multiline"
static NSString *const | kSecureTextEntry = @"@"obscureText"
static NSString *const | kTextInputAction = @"@"inputAction"
static NSString *const | kEnableDeltaModel = @"@"enableDeltaModel"
static NSString *const | kTextInputType = @"@"inputType"
static NSString *const | kTextInputTypeName = @"@"name"
static NSString *const | kSelectionBaseKey = @"@"selectionBase"
static NSString *const | kSelectionExtentKey = @"@"selectionExtent"
static NSString *const | kSelectionAffinityKey = @"@"selectionAffinity"
static NSString *const | kSelectionIsDirectionalKey = @"@"selectionIsDirectional"
static NSString *const | kComposingBaseKey = @"@"composingBase"
static NSString *const | kComposingExtentKey = @"@"composingExtent"
static NSString *const | kTextKey = @"@"text"
static NSString *const | kTransformKey = @"@"transform"
static NSString *const | kAssociatedAutofillFields = @"@"fields"
static NSString *const | kAutofillProperties = @"@"autofill"
static NSString *const | kAutofillId = @"@"uniqueIdentifier"
static NSString *const | kAutofillEditingValue = @"@"editingValue"
static NSString *const | kAutofillHints = @"@"hints"
static NSString *const | kTextAffinityDownstream = @"@"TextAffinity.downstream"
static NSString *const | kTextAffinityUpstream = @"@"TextAffinity.upstream"
static NSString *const | kInputActionNewline = @"@"TextInputAction.newline"
static char | markerKey
CATransform3D | _editableTransform
CGRect | _caretRect

## Function Documentation

## ◆ EnableAutocomplete()

static BOOL EnableAutocomplete | ( | NSDictionary * | configuration | ) |
| static

Definition at line 157 of file FlutterTextInputPlugin.mm.

157 {
158 for (NSDictionary* field in configuration[kAssociatedAutofillFields]) {
159 if (!EnableAutocompleteForTextInputConfiguration(field)) {
160 return NO;
161 }
162 }
163
164 // Check the top-level TextInputConfiguration.
165 return EnableAutocompleteForTextInputConfiguration(configuration);
166 }

References EnableAutocompleteForTextInputConfiguration(), and kAssociatedAutofillFields.

## ◆ EnableAutocompleteForTextInputConfiguration()

static BOOL EnableAutocompleteForTextInputConfiguration | ( | NSDictionary * | configuration | ) |
| static

Definition at line 129 of file FlutterTextInputPlugin.mm.

129 {
130 // Disable if obscureText is set.
131 if ([configuration[kSecureTextEntry] boolValue]) {
132 return NO;
133 }
134
135 // Disable if autofill properties are not set.
136 NSDictionary* autofill = configuration[kAutofillProperties];
137 if (autofill == nil) {
138 return NO;
139 }
140
141 // Disable if autofill properties indicate a username/password.
142 // See: https://github.com/flutter/flutter/issues/119824
143 NSString* hint = GetAutofillHint(autofill);
144 if ([hint isEqualToString:@"password"] || [hint isEqualToString:@"username"]) {
145 return NO;
146 }
147 return YES;
148 }

References GetAutofillHint(), kAutofillProperties, and kSecureTextEntry.

Referenced by EnableAutocomplete().

## ◆ GetAutofillHint()

static NSString* GetAutofillHint | ( | NSDictionary * | autofill | ) |
| static

Definition at line 96 of file FlutterTextInputPlugin.mm.

96 {
97 NSArray<NSString*>* hints = autofill[kAutofillHints];
98 return hints.count > 0 ? hints[0] : nil;
99 }

References kAutofillHints.

Referenced by EnableAutocompleteForTextInputConfiguration(), and GetTextContentType().

## ◆ GetTextContentType()

static NSTextContentType GetTextContentType | ( | NSDictionary * | configuration | ) |
| static

Definition at line 103 of file FlutterTextInputPlugin.mm.

104 {
105 // Check autofill hints.
106 NSDictionary* autofill = configuration[kAutofillProperties];
107 if (autofill) {
108 NSString* hint = GetAutofillHint(autofill);
109 if ([hint isEqualToString:@"username"]) {
110 return NSTextContentTypeUsername;
111 }
112 if ([hint isEqualToString:@"password"]) {
113 return NSTextContentTypePassword;
114 }
115 if ([hint isEqualToString:@"oneTimeCode"]) {
116 return NSTextContentTypeOneTimeCode;
117 }
118 }
119 // If no autofill hints, guess based on other attributes.
120 if ([configuration[kSecureTextEntry] boolValue]) {
121 return NSTextContentTypePassword;
122 }
123 return nil;
124 }

References GetAutofillHint(), kAutofillProperties, and kSecureTextEntry.

## ◆ NS_ENUM()

typedef NS_ENUM | ( | NSUInteger | ,
|  | FlutterTextAffinity |
| ) |  |

The affinity of the current cursor position. If the cursor is at a position representing a line break, the cursor may be drawn either at the end of the current line (upstream) or at the beginning of the next (downstream).

Definition at line 73 of file FlutterTextInputPlugin.mm.

73 {
74 kFlutterTextAffinityUpstream,
75 kFlutterTextAffinityDownstream
76 };

## ◆ RangeFromBaseExtent()

static flutter::TextRange RangeFromBaseExtent | ( | NSNumber * | base,
|  | NSNumber * | extent,
|  | const flutter::TextRange & | range
| ) |  |
| static

Definition at line 83 of file FlutterTextInputPlugin.mm.

85 {
86 if (base == nil || extent == nil) {
87 return range;
88 }
89 if (base.intValue == -1 && extent.intValue == -1) {
90 return flutter::TextRange(0, 0);
91 }
92 return flutter::TextRange([base unsignedLongValue], [extent unsignedLongValue]);
93 }

## Variable Documentation

## ◆ _caretRect

CGRect _caretRect

Current position of caret in local (editable) coordinates.

Definition at line 338 of file FlutterTextInputPlugin.mm.

Referenced by FlutterTextInputPlugin::initWithViewController:.

## ◆ _editableTransform

CATransform3D _editableTransform

Initial value:
{
std::unique_ptr<flutter::TextInputModel> _activeModel

Transform for current the editable. Used to determine position of accent selection menu.

Definition at line 324 of file FlutterTextInputPlugin.mm.

Referenced by FlutterTextInputPlugin::initWithViewController:.

## ◆ kAssociatedAutofillFields

NSString* const kAssociatedAutofillFields = @"@"fields"
| static

Definition at line 52 of file FlutterTextInputPlugin.mm.

Referenced by EnableAutocomplete().

## ◆ kAutofillEditingValue

NSString* const kAutofillEditingValue = @"@"editingValue"
| static

Definition at line 57 of file FlutterTextInputPlugin.mm.

## ◆ kAutofillHints

NSString* const kAutofillHints = @"@"hints"
| static

Definition at line 58 of file FlutterTextInputPlugin.mm.

Referenced by GetAutofillHint().

## ◆ kAutofillId

NSString* const kAutofillId = @"@"uniqueIdentifier"
| static

Definition at line 56 of file FlutterTextInputPlugin.mm.

## ◆ kAutofillProperties

NSString* const kAutofillProperties = @"@"autofill"
| static

Definition at line 55 of file FlutterTextInputPlugin.mm.

Referenced by EnableAutocompleteForTextInputConfiguration(), and GetTextContentType().

## ◆ kClearClientMethod

NSString* const kClearClientMethod = @"@"TextInput.clearClient"
| static

Definition at line 27 of file FlutterTextInputPlugin.mm.

## ◆ kComposingBaseKey

NSString* const kComposingBaseKey = @"@"composingBase"
| static

Definition at line 48 of file FlutterTextInputPlugin.mm.

## ◆ kComposingExtentKey

NSString* const kComposingExtentKey = @"@"composingExtent"
| static

Definition at line 49 of file FlutterTextInputPlugin.mm.

## ◆ kEnableDeltaModel

NSString* const kEnableDeltaModel = @"@"enableDeltaModel"
| static

Definition at line 41 of file FlutterTextInputPlugin.mm.

## ◆ kHideMethod

NSString* const kHideMethod = @"@"TextInput.hide"
| static

Definition at line 26 of file FlutterTextInputPlugin.mm.

## ◆ kInputActionNewline

NSString* const kInputActionNewline = @"@"TextInputAction.newline"
| static

Definition at line 65 of file FlutterTextInputPlugin.mm.

## ◆ kMultilineInputType

NSString* const kMultilineInputType = @"@"TextInputType.multiline"
| static

Definition at line 36 of file FlutterTextInputPlugin.mm.

## ◆ kPerformAction

NSString* const kPerformAction = @"@"TextInputClient.performAction"
| static

Definition at line 34 of file FlutterTextInputPlugin.mm.

## ◆ kPerformSelectors

NSString* const kPerformSelectors = @"@"TextInputClient.performSelectors"
| static

Definition at line 35 of file FlutterTextInputPlugin.mm.

## ◆ kSecureTextEntry

NSString* const kSecureTextEntry = @"@"obscureText"
| static

Definition at line 39 of file FlutterTextInputPlugin.mm.

Referenced by EnableAutocompleteForTextInputConfiguration(), and GetTextContentType().

## ◆ kSelectionAffinityKey

NSString* const kSelectionAffinityKey = @"@"selectionAffinity"
| static

Definition at line 46 of file FlutterTextInputPlugin.mm.

## ◆ kSelectionBaseKey

NSString* const kSelectionBaseKey = @"@"selectionBase"
| static

Definition at line 44 of file FlutterTextInputPlugin.mm.

## ◆ kSelectionExtentKey

NSString* const kSelectionExtentKey = @"@"selectionExtent"
| static

Definition at line 45 of file FlutterTextInputPlugin.mm.

## ◆ kSelectionIsDirectionalKey

NSString* const kSelectionIsDirectionalKey = @"@"selectionIsDirectional"
| static

Definition at line 47 of file FlutterTextInputPlugin.mm.

## ◆ kSetCaretRect

NSString* const kSetCaretRect = @"@"TextInput.setCaretRect"
| static

Definition at line 30 of file FlutterTextInputPlugin.mm.

## ◆ kSetClientMethod

NSString* const kSetClientMethod = @"@"TextInput.setClient"
| static

Definition at line 24 of file FlutterTextInputPlugin.mm.

## ◆ kSetEditableSizeAndTransform

NSString* const kSetEditableSizeAndTransform = @"@"TextInput.setEditableSizeAndTransform"
| static

Definition at line 29 of file FlutterTextInputPlugin.mm.

## ◆ kSetEditingStateMethod

NSString* const kSetEditingStateMethod = @"@"TextInput.setEditingState"
| static

Definition at line 28 of file FlutterTextInputPlugin.mm.

## ◆ kShowMethod

NSString* const kShowMethod = @"@"TextInput.show"
| static

Definition at line 25 of file FlutterTextInputPlugin.mm.

## ◆ kTextAffinityDownstream

NSString* const kTextAffinityDownstream = @"@"TextAffinity.downstream"
| static

Definition at line 61 of file FlutterTextInputPlugin.mm.

## ◆ kTextAffinityUpstream

NSString* const kTextAffinityUpstream = @"@"TextAffinity.upstream"
| static

Definition at line 62 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputAction

NSString* const kTextInputAction = @"@"inputAction"
| static

Definition at line 40 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputChannel

NSString* const kTextInputChannel = @"@"flutter/textinput"
| static

Definition at line 20 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputType

NSString* const kTextInputType = @"@"inputType"
| static

Definition at line 42 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputTypeName

NSString* const kTextInputTypeName = @"@"name"
| static

Definition at line 43 of file FlutterTextInputPlugin.mm.

## ◆ kTextKey

NSString* const kTextKey = @"@"text"
| static

Definition at line 50 of file FlutterTextInputPlugin.mm.

## ◆ kTransformKey

NSString* const kTransformKey = @"@"transform"
| static

Definition at line 51 of file FlutterTextInputPlugin.mm.

## ◆ kUpdateEditStateResponseMethod

NSString* const kUpdateEditStateResponseMethod = @"@"TextInputClient.updateEditingState"
| static

Definition at line 31 of file FlutterTextInputPlugin.mm.

## ◆ kUpdateEditStateWithDeltasResponseMethod

NSString* const kUpdateEditStateWithDeltasResponseMethod
| static

Initial value:
=
@"@"TextInputClient.updateEditingStateWithDeltas"

Definition at line 32 of file FlutterTextInputPlugin.mm.

## ◆ markerKey

char markerKey
| static

Definition at line 187 of file FlutterTextInputPlugin.mm.

Referenced by NSEvent(KeyEquivalentMarker)::markAsKeyEquivalent.

EnableAutocompleteForTextInputConfiguration
static BOOL EnableAutocompleteForTextInputConfiguration(NSDictionary *configuration)
Definition: FlutterTextInputPlugin.mm:129
kAutofillProperties
static NSString *const kAutofillProperties
Definition: FlutterTextInputPlugin.mm:55
kSecureTextEntry
static NSString *const kSecureTextEntry
Definition: FlutterTextInputPlugin.mm:39
kAssociatedAutofillFields
static NSString *const kAssociatedAutofillFields
Definition: FlutterTextInputPlugin.mm:52
flutter::TextRange
Definition: text_range.h:19
GetAutofillHint
static NSString * GetAutofillHint(NSDictionary *autofill)
Definition: FlutterTextInputPlugin.mm:96
kAutofillHints
static NSString *const kAutofillHints
Definition: FlutterTextInputPlugin.mm:58