| 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"`
`#import "flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.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 | kViewId = @"@"viewId"
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

## Function Documentation

## ◆ EnableAutocomplete()

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

Definition at line 159 of file FlutterTextInputPlugin.mm.

159 {
160 for (NSDictionary* field in configuration[kAssociatedAutofillFields]) {
161 if (!EnableAutocompleteForTextInputConfiguration(field)) {
162 return NO;
163 }
164 }
165
166 // Check the top-level TextInputConfiguration.
167 return EnableAutocompleteForTextInputConfiguration(configuration);
168 }
kAssociatedAutofillFields
static NSString *const kAssociatedAutofillFields
Definition: FlutterTextInputPlugin.mm:54
EnableAutocompleteForTextInputConfiguration
static BOOL EnableAutocompleteForTextInputConfiguration(NSDictionary *configuration)
Definition: FlutterTextInputPlugin.mm:131

References EnableAutocompleteForTextInputConfiguration(), and kAssociatedAutofillFields.

## ◆ EnableAutocompleteForTextInputConfiguration()

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

Definition at line 131 of file FlutterTextInputPlugin.mm.

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

References GetAutofillHint(), kAutofillProperties, and kSecureTextEntry.

Referenced by EnableAutocomplete().

## ◆ GetAutofillHint()

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

Definition at line 98 of file FlutterTextInputPlugin.mm.

98 {
99 NSArray<NSString*>* hints = autofill[kAutofillHints];
100 return hints.count > 0 ? hints[0] : nil;
101 }
kAutofillHints
static NSString *const kAutofillHints
Definition: FlutterTextInputPlugin.mm:60

References kAutofillHints.

Referenced by EnableAutocompleteForTextInputConfiguration(), and GetTextContentType().

## ◆ GetTextContentType()

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

Definition at line 105 of file FlutterTextInputPlugin.mm.

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

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 soft 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 75 of file FlutterTextInputPlugin.mm.

75 {
76 kFlutterTextAffinityUpstream,
77 kFlutterTextAffinityDownstream
78 };

## ◆ RangeFromBaseExtent()

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

Definition at line 85 of file FlutterTextInputPlugin.mm.

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

## Variable Documentation

## ◆ kAssociatedAutofillFields

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

Definition at line 54 of file FlutterTextInputPlugin.mm.

Referenced by EnableAutocomplete().

## ◆ kAutofillEditingValue

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

Definition at line 59 of file FlutterTextInputPlugin.mm.

## ◆ kAutofillHints

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

Definition at line 60 of file FlutterTextInputPlugin.mm.

Referenced by GetAutofillHint().

## ◆ kAutofillId

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

Definition at line 58 of file FlutterTextInputPlugin.mm.

## ◆ kAutofillProperties

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

Definition at line 57 of file FlutterTextInputPlugin.mm.

Referenced by EnableAutocompleteForTextInputConfiguration(), and GetTextContentType().

## ◆ kClearClientMethod

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

Definition at line 28 of file FlutterTextInputPlugin.mm.

## ◆ kComposingBaseKey

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

Definition at line 50 of file FlutterTextInputPlugin.mm.

## ◆ kComposingExtentKey

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

Definition at line 51 of file FlutterTextInputPlugin.mm.

## ◆ kEnableDeltaModel

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

Definition at line 43 of file FlutterTextInputPlugin.mm.

## ◆ kHideMethod

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

Definition at line 27 of file FlutterTextInputPlugin.mm.

## ◆ kInputActionNewline

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

Definition at line 67 of file FlutterTextInputPlugin.mm.

## ◆ kMultilineInputType

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

Definition at line 37 of file FlutterTextInputPlugin.mm.

## ◆ kPerformAction

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

Definition at line 35 of file FlutterTextInputPlugin.mm.

## ◆ kPerformSelectors

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

Definition at line 36 of file FlutterTextInputPlugin.mm.

## ◆ kSecureTextEntry

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

Definition at line 41 of file FlutterTextInputPlugin.mm.

Referenced by EnableAutocompleteForTextInputConfiguration(), and GetTextContentType().

## ◆ kSelectionAffinityKey

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

Definition at line 48 of file FlutterTextInputPlugin.mm.

## ◆ kSelectionBaseKey

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

Definition at line 46 of file FlutterTextInputPlugin.mm.

## ◆ kSelectionExtentKey

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

Definition at line 47 of file FlutterTextInputPlugin.mm.

## ◆ kSelectionIsDirectionalKey

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

Definition at line 49 of file FlutterTextInputPlugin.mm.

## ◆ kSetCaretRect

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

Definition at line 31 of file FlutterTextInputPlugin.mm.

## ◆ kSetClientMethod

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

Definition at line 25 of file FlutterTextInputPlugin.mm.

## ◆ kSetEditableSizeAndTransform

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

Definition at line 30 of file FlutterTextInputPlugin.mm.

## ◆ kSetEditingStateMethod

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

Definition at line 29 of file FlutterTextInputPlugin.mm.

## ◆ kShowMethod

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

Definition at line 26 of file FlutterTextInputPlugin.mm.

## ◆ kTextAffinityDownstream

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

Definition at line 63 of file FlutterTextInputPlugin.mm.

## ◆ kTextAffinityUpstream

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

Definition at line 64 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputAction

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

Definition at line 42 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputChannel

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

Definition at line 21 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputType

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

Definition at line 44 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputTypeName

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

Definition at line 45 of file FlutterTextInputPlugin.mm.

## ◆ kTextKey

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

Definition at line 52 of file FlutterTextInputPlugin.mm.

## ◆ kTransformKey

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

Definition at line 53 of file FlutterTextInputPlugin.mm.

## ◆ kUpdateEditStateResponseMethod

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

Definition at line 32 of file FlutterTextInputPlugin.mm.

## ◆ kUpdateEditStateWithDeltasResponseMethod

NSString* const kUpdateEditStateWithDeltasResponseMethod
| static

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

Definition at line 33 of file FlutterTextInputPlugin.mm.

## ◆ kViewId

NSString* const kViewId = @"@"viewId"
| static

Definition at line 40 of file FlutterTextInputPlugin.mm.

## ◆ markerKey

char markerKey
| static

Definition at line 189 of file FlutterTextInputPlugin.mm.

Referenced by NSEvent(KeyEquivalentMarker)::isKeyEquivalent.