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