| Flutter macOS Embedder |

FlutterKeyboardViewDelegate.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
7 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
8 #import "flutter/shell/platform/embedder/embedder.h"
9
10 namespace flutter {
11
12 // Signature used to notify that a keyboard layout has changed.
13 typedef void (^KeyboardLayoutNotifier)();
14
15 // The printable result of a key under certain modifiers, used to derive key
16 // mapping.
17 typedef struct {
18 // The printable character.
19 //
20 // If `isDeadKey` is true, then this is the character when pressing the same
21 // dead key twice.
22 uint32_t character;
23
24 // Whether this character is a dead key.
25 //
26 // A dead key is a key that is not counted as text per se, but holds a
27 // diacritics to be added to the next key.
28 bool isDeadKey;
29 } LayoutClue;
30
31 } // namespace flutter
32
33 /**
34 * An interface for a class that can provides |FlutterKeyboardManager| with
35 * platform-related features.
36 *
37 * This protocol is typically implemented by |FlutterViewController|.
38 */
39 @protocol FlutterKeyboardViewDelegate
40
41 @required
42 /**
43 * Get the next responder to dispatch events that the keyboard system
44 * (including text input) do not handle.
45 *
46 * If the |nextResponder| is null, then those events will be discarded.
47 */
48 @property(nonatomic, readonly, nullable) NSResponder* nextResponder;
49
50 /**
51 * Dispatch events to the framework to be processed by |HardwareKeyboard|.
52 *
53 * This method typically forwards events to
54 * |FlutterEngine.sendKeyEvent:callback:userData:|.
55 */
56 - (void)sendKeyEvent:(const FlutterKeyEvent&)event
57 callback:(nullable FlutterKeyEventCallback)callback
58 userData:(nullable void*)userData;
59
60 /**
61 * Get a binary messenger to send channel messages with.
62 *
63 * This method is used to create the key data channel and typically
64 * forwards to |FlutterEngine.binaryMessenger|.
65 */
66 - (nonnull id<FlutterBinaryMessenger>)getBinaryMessenger;
67
68 /**
69 * Dispatch events that are not handled by the keyboard event handlers
70 * to the text input handler.
71 *
72 * This method typically forwards events to |TextInputPlugin.handleKeyEvent|.
73 */
74 - (BOOL)onTextInputKeyEvent:(nonnull NSEvent*)event;
75
76 /**
77 * Add a listener that is called whenever the user changes keyboard layout.
78 *
79 * Only one listeners is supported. Adding new ones overwrites the current one.
80 * Assigning nil unsubscribes.
81 */
82 - (void)subscribeToKeyboardLayoutChange:(nullable flutter::KeyboardLayoutNotifier)callback;
83
84 /**
85 * Querying the printable result of a key under the given modifier state.
86 */
87 - (flutter::LayoutClue)lookUpLayoutForKeyCode:(uint16_t)keyCode shift:(BOOL)shift;
88
89 /**
90 * Returns the keyboard pressed state.
91 *
92 * Returns the keyboard pressed state. The dictionary contains one entry per
93 * pressed keys, mapping from the logical key to the physical key.
94 */
95 - (nonnull NSDictionary*)getPressedState;
96
97 @end
flutter::LayoutClue
Definition: FlutterKeyboardViewDelegate.h:17
FlutterKeyboardViewDelegate-p
Definition: FlutterKeyboardViewDelegate.h:39
flutter::LayoutClue::character
uint32_t character
Definition: FlutterKeyboardViewDelegate.h:22
flutter::KeyboardLayoutNotifier
void(^ KeyboardLayoutNotifier)()
Definition: FlutterKeyboardViewDelegate.h:13
flutter
Definition: AccessibilityBridgeMac.h:16
FlutterBinaryMessenger.h
FlutterKeyboardViewDelegate-p::nextResponder
NSResponder * nextResponder
Definition: FlutterKeyboardViewDelegate.h:48
FlutterBinaryMessenger-p
Definition: FlutterBinaryMessenger.h:49
-[FlutterKeyboardViewDelegate-p getBinaryMessenger]
nonnull id< FlutterBinaryMessenger > getBinaryMessenger()
flutter::LayoutClue::isDeadKey
bool isDeadKey
Definition: FlutterKeyboardViewDelegate.h:28
-[FlutterKeyboardViewDelegate-p getPressedState]
nonnull NSDictionary * getPressedState()