Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FlutterKeyboardManager.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_FLUTTERKEYBOARDMANAGER_H_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERKEYBOARDMANAGER_H_
7
8#import <Cocoa/Cocoa.h>
9
10#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyboardViewDelegate.h"
11
12/**
13 * Processes keyboard events and cooperate with |TextInputPlugin|.
14 *
15 * A keyboard event goes through a few sections, each can choose to handled the
16 * event, and only unhandled events can move to the next section:
17 *
18 * - Pre-filtering: Events during IME are sent to the system immediately.
19 * - Keyboard: Dispatch to the embedder responder and the channel responder
20 * simultaneously. After both responders have responded (asynchronously), the
21 * event is considered handled if either responder handles.
22 * - Text input: Events are sent to |TextInputPlugin| and are handled
23 * synchronously.
24 * - Next responder: Events are sent to the next responder as specified by
25 * |viewDelegate|.
26 */
27@interface FlutterKeyboardManager : NSObject
28
29/**
30 * Create a keyboard manager.
31 *
32 * The |viewDelegate| is a weak reference, typically implemented by
33 * |FlutterViewController|.
34 */
35- (nonnull instancetype)initWithViewDelegate:(nonnull id<FlutterKeyboardViewDelegate>)viewDelegate;
36
37/**
38 * Processes a key event.
39 *
40 * Unhandled events will be dispatched to the text input system, and possibly
41 * the next responder afterwards.
42 */
43- (void)handleEvent:(nonnull NSEvent*)event;
44
45/**
46 * Returns yes if is event currently being redispatched.
47 *
48 * In some instances (i.e. emoji shortcut) the event may be redelivered by cocoa
49 * as key equivalent to FlutterTextInput, in which case it shouldn't be
50 * processed again.
51 */
52- (BOOL)isDispatchingKeyEvent:(nonnull NSEvent*)event;
53
54/**
55 * Synthesize modifier keys events.
56 *
57 * If needed, synthesize modifier keys up and down events by comparing their
58 * current pressing states with the given modifier flags.
59 */
60- (void)syncModifiersIfNeeded:(NSEventModifierFlags)modifierFlags
61 timestamp:(NSTimeInterval)timestamp;
62
63/**
64 * Returns the keyboard pressed state.
65 *
66 * Returns the keyboard pressed state. The dictionary contains one entry per
67 * pressed keys, mapping from the logical key to the physical key.
68 */
69- (nonnull NSDictionary*)getPressedState;
70
71@end
72
73#endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERKEYBOARDMANAGER_H_
nonnull NSDictionary * getPressedState()
int BOOL