Flutter macOS Embedder
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 #import <Cocoa/Cocoa.h>
6 
9 
10 @class FlutterTextField;
11 
12 /**
13  * A plugin to handle text input.
14  *
15  * Responsible for bridging the native macOS text input system with the Flutter framework text
16  * editing classes, via system channels.
17  *
18  * This is not an FlutterPlugin since it needs access to FlutterViewController internals, so needs
19  * to be managed differently.
20  *
21  * When accessibility is on, accessibility bridge creates a NSTextField, i.e. FlutterTextField,
22  * for every text field in the Flutter. This plugin acts as a field editor for those NSTextField[s].
23  */
24 @interface FlutterTextInputPlugin : NSTextView
25 
26 /**
27  * The NSTextField that currently has this plugin as its field editor.
28  *
29  * Must be nil if accessibility is off.
30  */
31 @property(nonatomic, weak) FlutterTextField* client;
32 
33 /**
34  * Initializes a text input plugin that coordinates key event handling with |viewController|.
35  */
36 - (instancetype)initWithViewController:(FlutterViewController*)viewController;
37 
38 /**
39  * Whether this plugin is the first responder of this NSWindow.
40  *
41  * When accessibility is on, this plugin is set as the first responder to act as the field
42  * editor for FlutterTextFields.
43  *
44  * Returns false if accessibility is off.
45  */
46 - (BOOL)isFirstResponder;
47 
48 /**
49  * Handles key down events received from the view controller, responding YES if
50  * the event was handled.
51  *
52  * Note, the Apple docs suggest that clients should override essentially all the
53  * mouse and keyboard event-handling methods of NSResponder. However, experimentation
54  * indicates that only key events are processed by the native layer; Flutter processes
55  * mouse events. Additionally, processing both keyUp and keyDown results in duplicate
56  * processing of the same keys.
57  */
58 - (BOOL)handleKeyEvent:(NSEvent*)event;
59 
60 @end
61 
62 // Private methods made visible for testing
64 - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
65 - (NSRect)firstRectForCharacterRange:(NSRange)range actualRange:(NSRangePointer)actualRange;
66 - (NSDictionary*)editingState;
67 @property(nonatomic) NSTextInputContext* textInputContext;
68 @property(readwrite, nonatomic) NSString* customRunLoopMode;
69 @end
-[FlutterTextInputPlugin(TestMethods) editingState]
NSDictionary * editingState()
FlutterTextInputPlugin(TestMethods)
Definition: FlutterTextInputPlugin.h:63
FlutterTextInputPlugin(TestMethods)::customRunLoopMode
NSString * customRunLoopMode
Definition: FlutterTextInputPlugin.h:68
FlutterViewController
Definition: FlutterViewController.h:62
FlutterTextInputPlugin::client
FlutterTextField * client
Definition: FlutterTextInputPlugin.h:31
FlutterMethodCall
Definition: FlutterCodecs.h:220
FlutterBinaryMessenger.h
FlutterTextInputPlugin
Definition: FlutterTextInputPlugin.h:24
FlutterTextInputPlugin(TestMethods)::textInputContext
NSTextInputContext * textInputContext
Definition: FlutterTextInputPlugin.h:67
FlutterResult
void(^ FlutterResult)(id _Nullable result)
Definition: FlutterChannels.h:194
-[FlutterTextInputPlugin isFirstResponder]
BOOL isFirstResponder()
Definition: FlutterTextInputPlugin.mm:373
FlutterTextField
Definition: FlutterTextInputSemanticsObject.h:78
FlutterViewController.h