| Flutter iOS Embedder |

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_IOS_FRAMEWORK_SOURCE_FLUTTER_KEYBOARD_MANAGER_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTER_KEYBOARD_MANAGER_H_
7
8 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyPrimaryResponder.h"
9
10 #import <Foundation/NSObject.h>
11 #import <UIKit/UIKit.h>
12
13 #include "flutter/fml/memory/weak_ptr.h"
14 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyPrimaryResponder.h"
15 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySecondaryResponder.h"
16 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h"
17
18 typedef void (^KeyEventCompleteCallback)(bool, FlutterUIPressProxy* _Nonnull)
19 API_AVAILABLE(ios(13.4));
20
21 /**
22 * A hub that manages how key events are dispatched to various Flutter key
23 * responders, and propagates it to the superclass if the Flutter key responders
24 * do not handle it.
25 *
26 * This class manages one or more primary responders, as well as zero or more
27 * secondary responders.
28 *
29 * An event that is received by |handlePresses| is first dispatched to *all*
30 * primary responders. Each primary responder responds *asynchronously* with a
31 * boolean, indicating whether it handles the event.
32 *
33 * An event that is not handled by any primary responders is then passed to to
34 * the first secondary responder (in the chronological order of addition),
35 * which responds *synchronously* with a boolean, indicating whether it handles
36 * the event. If not, the event is passed to the next secondary responder, and
37 * so on.
38 *
39 * The event is then handed back to the |completeCallback| from the original
40 * call to |handlePresses| so that it can respond synchronously to the OS if the
41 * event was not handled by the responders. The |completeCallback| is called on
42 * the platform thread because the platform thread is blocked by a nested event
43 * loop while the response from the framework is being collected, and it needs
44 * to be called on the platform thread to unblock the thread by exiting the
45 * nested event loop.
46 *
47 * Preventing primary responders from receiving events is not supported, because
48 * in reality this class only supports two hardcoded responders
49 * (FlutterChannelKeyResponder and FlutterEmbedderKeyResponder), where the only purpose
50 * of supporting two is to maintain the legacy channel API during the
51 * deprecation window, after which the channel responder should be removed, and
52 * only one primary responder will exist.
53 */
54 @interface FlutterKeyboardManager : NSObject
55 /**
56 * Add a primary responder, which asynchronously decides whether to handle an
57 * event.
58 */
59 - (void)addPrimaryResponder:(nonnull id<FlutterKeyPrimaryResponder>)responder;
60
61 /**
62 * Add a secondary responder, which synchronously decides whether to handle an
63 * event in order if no earlier responders handle.
64 */
65 - (void)addSecondaryResponder:(nonnull id<FlutterKeySecondaryResponder>)responder;
66
67 /**
68 * Dispatches a key press event to all responders, gathering their responses,
69 * and then calls the |nextAction| if the event was not handled.
70 */
71 - (void)handlePress:(nonnull FlutterUIPressProxy*)press
72 nextAction:(nonnull void (^)())next API_AVAILABLE(ios(13.4));
73 @end
74
75 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTER_KEYBOARD_MANAGER_H_
FlutterKeyPrimaryResponder-p
Definition: FlutterKeyPrimaryResponder.h:19
API_AVAILABLE
UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0))
FlutterKeyPrimaryResponder.h
FlutterKeySecondaryResponder-p
Definition: FlutterKeySecondaryResponder.h:17
KeyEventCompleteCallback
void(^ KeyEventCompleteCallback)(bool, FlutterUIPressProxy *_Nonnull) API_AVAILABLE(ios(13.4))
Definition: FlutterKeyboardManager.h:18
FlutterUIPressProxy
Definition: FlutterUIPressProxy.h:17
FlutterUIPressProxy.h
FlutterKeySecondaryResponder.h
FlutterKeyboardManager
Definition: FlutterKeyboardManager.h:54