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