Flutter macOS Embedder
FlutterKeyPrimaryResponder.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_FLUTTERKEYPRIMARYRESPONDER_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERKEYPRIMARYRESPONDER_H_
7 
8 #import <Cocoa/Cocoa.h>
9 
10 typedef void (^FlutterAsyncKeyCallback)(BOOL handled);
11 
12 /**
13  * An interface for a responder that can process a key event and decides whether
14  * to handle an event asynchronously.
15  *
16  * To use this class, add it to a |FlutterKeyboardManager| with |addPrimaryResponder|.
17  */
19 
20 /**
21  * Process the event.
22  *
23  * The |callback| should be called with a value that indicates whether the
24  * responder has handled the given event. The |callback| must be called exactly
25  * once, and can be called before the return of this method, or after.
26  */
27 @required
28 - (void)handleEvent:(nonnull NSEvent*)event callback:(nonnull FlutterAsyncKeyCallback)callback;
29 
30 /**
31  * Synchronize the modifier flags if necessary. The new modifier flag would usually come from mouse
32  * event and may be out of sync with current keyboard state if the modifier flags have changed while
33  * window was not key.
34  */
35 @required
36 - (void)syncModifiersIfNeeded:(NSEventModifierFlags)modifierFlags
37  timestamp:(NSTimeInterval)timestamp;
38 
39 /* A map from macOS key code to logical keyboard.
40  *
41  * The map is assigned on initialization, and updated when the user changes
42  * keyboard type or layout. The responder should prioritize this map when
43  * deriving logical keys.
44  */
45 @required
46 @property(nonatomic, nullable, strong) NSMutableDictionary<NSNumber*, NSNumber*>* layoutMap;
47 
48 @end
49 
50 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERKEYPRIMARYRESPONDER_H_
FlutterKeyPrimaryResponder-p
Definition: FlutterKeyPrimaryResponder.h:18
FlutterAsyncKeyCallback
void(^ FlutterAsyncKeyCallback)(BOOL handled)
Definition: FlutterKeyPrimaryResponder.h:10
FlutterKeyPrimaryResponder-p::layoutMap
NSMutableDictionary< NSNumber *, NSNumber * > * layoutMap
Definition: FlutterKeyPrimaryResponder.h:46