Flutter Engine
The Flutter Engine
|
#import <FlutterKeyboardManager.h>
Instance Methods | |
(void) | - addPrimaryResponder: |
(void) | - addSecondaryResponder: |
(void) | - handlePress:nextAction: |
(nonnull instancetype) | - initWithViewDelegate: |
(void) | - handleEvent: |
(BOOL) | - isDispatchingKeyEvent: |
(void) | - syncModifiersIfNeeded:timestamp: |
(nonnull NSDictionary *) | - getPressedState |
(nonnull instancetype) | - init [implementation] |
(void) | - dispatchToSecondaryResponders:complete: [implementation] |
(void) | - handleKeyboardMethodCall:result: [implementation] |
(BOOL) | - isDispatchingKeyEvent: [implementation] |
(void) | - processNextEvent [implementation] |
(void) | - performProcessEvent:onFinish: [implementation] |
(void) | - dispatchTextEvent: [implementation] |
(void) | - buildLayout [implementation] |
Properties | |
NSMutableArray< id< FlutterKeyPrimaryResponder > > * | primaryResponders [implementation] |
NSMutableArray< id< FlutterKeySecondaryResponder > > * | secondaryResponders [implementation] |
id< FlutterKeyboardViewDelegate > | viewDelegate [implementation] |
NSMutableArray< NSEvent * > * | pendingEvents [implementation] |
BOOL | processingEvent [implementation] |
NSMutableDictionary< NSNumber *, NSNumber * > * | layoutMap [implementation] |
NSEvent * | eventBeingDispatched [implementation] |
A hub that manages how key events are dispatched to various Flutter key responders, and propagates it to the superclass if the Flutter key responders do not handle it.
This class manages one or more primary responders, as well as zero or more secondary responders.
An event that is received by |handlePresses| is first dispatched to all primary responders. Each primary responder responds asynchronously with a boolean, indicating whether it handles the event.
An event that is not handled by any primary responders is then passed to to the first secondary responder (in the chronological order of addition), which responds synchronously with a boolean, indicating whether it handles the event. If not, the event is passed to the next secondary responder, and so on.
The event is then handed back to the |completeCallback| from the original call to |handlePresses| so that it can respond synchronously to the OS if the event was not handled by the responders. The |completeCallback| is called on the platform thread because the platform thread is blocked by a nested event loop while the response from the framework is being collected, and it needs to be called on the platform thread to unblock the thread by exiting the nested event loop.
Preventing primary responders from receiving events is not supported, because in reality this class only supports two hardcoded responders (FlutterChannelKeyResponder and FlutterEmbedderKeyResponder), where the only purpose of supporting two is to maintain the legacy channel API during the deprecation window, after which the channel responder should be removed, and only one primary responder will exist.
Processes keyboard events and cooperate with |TextInputPlugin|.
A keyboard event goes through a few sections, each can choose to handled the event, and only unhandled events can move to the next section:
Definition at line 53 of file FlutterKeyboardManager.h.
- (void) addPrimaryResponder: | (nonnull id<FlutterKeyPrimaryResponder>) | responder |
Add a primary responder, which asynchronously decides whether to handle an event.
Definition at line 26 of file FlutterKeyboardManager.mm.
- (void) addSecondaryResponder: | (nonnull id<FlutterKeySecondaryResponder>) | responder |
Add a secondary responder, which synchronously decides whether to handle an event in order if no earlier responders handle.
Definition at line 26 of file FlutterKeyboardManager.mm.
|
implementation |
Clears the current layout and build a new one based on the current layout.
Definition at line 73 of file FlutterKeyboardManager.mm.
|
implementation |
Definition at line 73 of file FlutterKeyboardManager.mm.
|
implementation |
Definition at line 26 of file FlutterKeyboardManager.mm.
- (nonnull NSDictionary *) getPressedState |
Returns the keyboard pressed state.
Returns the keyboard pressed state. The dictionary contains one entry per pressed keys, mapping from the logical key to the physical key.
Definition at line 73 of file FlutterKeyboardManager.mm.
- (void) handleEvent: | (nonnull NSEvent*) | event |
Processes a key event.
Unhandled events will be dispatched to the text input system, and possibly the next responder afterwards.
Definition at line 73 of file FlutterKeyboardManager.mm.
|
implementation |
Definition at line 73 of file FlutterKeyboardManager.mm.
- (void) handlePress: | (nonnull FlutterUIPressProxy*) | press | |
nextAction: | (ios(13.4)) | API_AVAILABLE | |
Dispatches a key press event to all responders, gathering their responses, and then calls the |nextAction| if the event was not handled.
Definition at line 26 of file FlutterKeyboardManager.mm.
|
implementation |
Definition at line 26 of file FlutterKeyboardManager.mm.
- (nonnull instancetype) initWithViewDelegate: | (nonnull id<FlutterKeyboardViewDelegate>) | viewDelegate |
Create a keyboard manager.
The |viewDelegate| is a weak reference, typically implemented by |FlutterViewController|.
Definition at line 73 of file FlutterKeyboardManager.mm.
- (BOOL) isDispatchingKeyEvent: | (nonnull NSEvent *) | event |
Returns yes if is event currently being redispatched.
In some instances (i.e. emoji shortcut) the event may be redelivered by cocoa as key equivalent to FlutterTextInput, in which case it shouldn't be processed again.
|
implementation |
Definition at line 73 of file FlutterKeyboardManager.mm.
|
implementation |
Definition at line 73 of file FlutterKeyboardManager.mm.
|
implementation |
Start processing the next event if not started already.
This function might initiate an async process, whose callback calls this function again.
Definition at line 73 of file FlutterKeyboardManager.mm.
- (void) syncModifiersIfNeeded: | (NSEventModifierFlags) | modifierFlags | |
timestamp: | (NSTimeInterval) | timestamp | |
Synthesize modifier keys events.
If needed, synthesize modifier keys up and down events by comparing their current pressing states with the given modifier flags.
Definition at line 73 of file FlutterKeyboardManager.mm.
|
readwritenonatomicassignimplementation |
Definition at line 73 of file FlutterKeyboardManager.mm.
|
readwritenonatomicassignimplementation |
Definition at line 71 of file FlutterKeyboardManager.mm.
|
readwritenonatomicassignimplementation |
Definition at line 67 of file FlutterKeyboardManager.mm.
|
readwritenonatomicassignimplementation |
The primary responders added by addPrimaryResponder.
Provided by category FlutterKeyboardManager(Tests).
Definition at line 20 of file FlutterKeyboardManager.mm.
|
readwritenonatomicassignimplementation |
Definition at line 69 of file FlutterKeyboardManager.mm.
|
readnonatomiccopyimplementation |
The secondary responders added by addSecondaryResponder.
Definition at line 26 of file FlutterKeyboardManager.mm.
|
readwritenonatomicweakimplementation |
The text input plugin set by initialization.
Definition at line 60 of file FlutterKeyboardManager.mm.