| 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/common/constants.h"`
`#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 160 of file FlutterTextInputPlugin.mm.

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

References EnableAutocompleteForTextInputConfiguration(), and kAssociatedAutofillFields.

## ◆ EnableAutocompleteForTextInputConfiguration()

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

Definition at line 132 of file FlutterTextInputPlugin.mm.

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

References GetAutofillHint(), kAutofillProperties, and kSecureTextEntry.

Referenced by EnableAutocomplete().

## ◆ GetAutofillHint()

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

Definition at line 99 of file FlutterTextInputPlugin.mm.

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

References kAutofillHints.

Referenced by EnableAutocompleteForTextInputConfiguration(), and GetTextContentType().

## ◆ GetTextContentType()

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

Definition at line 106 of file FlutterTextInputPlugin.mm.

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

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

76 {
77 kFlutterTextAffinityUpstream,
78 kFlutterTextAffinityDownstream
79 };

## ◆ RangeFromBaseExtent()

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

Definition at line 86 of file FlutterTextInputPlugin.mm.

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

## Variable Documentation

## ◆ kAssociatedAutofillFields

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

Definition at line 55 of file FlutterTextInputPlugin.mm.

Referenced by EnableAutocomplete().

## ◆ kAutofillEditingValue

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

Definition at line 60 of file FlutterTextInputPlugin.mm.

## ◆ kAutofillHints

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

Definition at line 61 of file FlutterTextInputPlugin.mm.

Referenced by GetAutofillHint().

## ◆ kAutofillId

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

Definition at line 59 of file FlutterTextInputPlugin.mm.

## ◆ kAutofillProperties

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

Definition at line 58 of file FlutterTextInputPlugin.mm.

Referenced by EnableAutocompleteForTextInputConfiguration(), and GetTextContentType().

## ◆ kClearClientMethod

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

Definition at line 29 of file FlutterTextInputPlugin.mm.

## ◆ kComposingBaseKey

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

Definition at line 51 of file FlutterTextInputPlugin.mm.

## ◆ kComposingExtentKey

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

Definition at line 52 of file FlutterTextInputPlugin.mm.

## ◆ kEnableDeltaModel

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

Definition at line 44 of file FlutterTextInputPlugin.mm.

## ◆ kHideMethod

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

Definition at line 28 of file FlutterTextInputPlugin.mm.

## ◆ kInputActionNewline

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

Definition at line 68 of file FlutterTextInputPlugin.mm.

## ◆ kMultilineInputType

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

Definition at line 38 of file FlutterTextInputPlugin.mm.

## ◆ kPerformAction

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

Definition at line 36 of file FlutterTextInputPlugin.mm.

## ◆ kPerformSelectors

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

Definition at line 37 of file FlutterTextInputPlugin.mm.

## ◆ kSecureTextEntry

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

Definition at line 42 of file FlutterTextInputPlugin.mm.

Referenced by EnableAutocompleteForTextInputConfiguration(), and GetTextContentType().

## ◆ kSelectionAffinityKey

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

Definition at line 49 of file FlutterTextInputPlugin.mm.

## ◆ kSelectionBaseKey

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

Definition at line 47 of file FlutterTextInputPlugin.mm.

## ◆ kSelectionExtentKey

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

Definition at line 48 of file FlutterTextInputPlugin.mm.

## ◆ kSelectionIsDirectionalKey

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

Definition at line 50 of file FlutterTextInputPlugin.mm.

## ◆ kSetCaretRect

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

Definition at line 32 of file FlutterTextInputPlugin.mm.

## ◆ kSetClientMethod

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

Definition at line 26 of file FlutterTextInputPlugin.mm.

## ◆ kSetEditableSizeAndTransform

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

Definition at line 31 of file FlutterTextInputPlugin.mm.

## ◆ kSetEditingStateMethod

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

Definition at line 30 of file FlutterTextInputPlugin.mm.

## ◆ kShowMethod

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

Definition at line 27 of file FlutterTextInputPlugin.mm.

## ◆ kTextAffinityDownstream

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

Definition at line 64 of file FlutterTextInputPlugin.mm.

## ◆ kTextAffinityUpstream

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

Definition at line 65 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputAction

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

Definition at line 43 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputChannel

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

Definition at line 22 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputType

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

Definition at line 45 of file FlutterTextInputPlugin.mm.

## ◆ kTextInputTypeName

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

Definition at line 46 of file FlutterTextInputPlugin.mm.

## ◆ kTextKey

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

Definition at line 53 of file FlutterTextInputPlugin.mm.

## ◆ kTransformKey

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

Definition at line 54 of file FlutterTextInputPlugin.mm.

## ◆ kUpdateEditStateResponseMethod

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

Definition at line 33 of file FlutterTextInputPlugin.mm.

## ◆ kUpdateEditStateWithDeltasResponseMethod

NSString* const kUpdateEditStateWithDeltasResponseMethod
| static

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

Definition at line 34 of file FlutterTextInputPlugin.mm.

## ◆ kViewId

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

Definition at line 41 of file FlutterTextInputPlugin.mm.

## ◆ markerKey

char markerKey
| static

Definition at line 190 of file FlutterTextInputPlugin.mm.

Referenced by NSEvent(KeyEquivalentMarker)::isKeyEquivalent.