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