Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
io.flutter.embedding.android.KeyChannelResponder Class Reference
Inheritance diagram for io.flutter.embedding.android.KeyChannelResponder:
io.flutter.embedding.android.KeyboardManager.Responder

Public Member Functions

 KeyChannelResponder (@NonNull KeyEventChannel keyEventChannel)
 
void handleEvent ( @NonNull KeyEvent keyEvent, @NonNull OnKeyEventHandledCallback onKeyEventHandledCallback)
 
void handleEvent ( @NonNull KeyEvent keyEvent, @NonNull OnKeyEventHandledCallback onKeyEventHandledCallback)
 

Detailed Description

A KeyboardManager.Responder of KeyboardManager that handles events by sending the raw information through the method channel.

This class corresponds to the RawKeyboard API in the framework.

Definition at line 17 of file KeyChannelResponder.java.

Constructor & Destructor Documentation

◆ KeyChannelResponder()

io.flutter.embedding.android.KeyChannelResponder.KeyChannelResponder ( @NonNull KeyEventChannel  keyEventChannel)
inline

Definition at line 26 of file KeyChannelResponder.java.

26 {
27 this.keyEventChannel = keyEventChannel;
28 }

Member Function Documentation

◆ handleEvent()

void io.flutter.embedding.android.KeyChannelResponder.handleEvent ( @NonNull KeyEvent  keyEvent,
@NonNull OnKeyEventHandledCallback  onKeyEventHandledCallback 
)
inline

Informs this Responder that a new KeyEvent needs processing.

Parameters
keyEventthe new KeyEvent this Responder may be interested in.
onKeyEventHandledCallbackthe method to call when this Responder has decided whether to handle the KeyEvent.

Implements io.flutter.embedding.android.KeyboardManager.Responder.

Definition at line 31 of file KeyChannelResponder.java.

32 {
33 final int action = keyEvent.getAction();
34 if (action != KeyEvent.ACTION_DOWN && action != KeyEvent.ACTION_UP) {
35 // There is theoretically a KeyEvent.ACTION_MULTIPLE, but theoretically
36 // that isn't sent by Android anymore, so this is just for protection in
37 // case the theory is wrong.
38 onKeyEventHandledCallback.onKeyEventHandled(false);
39 return;
40 }
41
42 final Character complexCharacter =
43 characterCombiner.applyCombiningCharacterToBaseCharacter(keyEvent.getUnicodeChar());
44 KeyEventChannel.FlutterKeyEvent flutterEvent =
45 new KeyEventChannel.FlutterKeyEvent(keyEvent, complexCharacter);
46
47 final boolean isKeyUp = action != KeyEvent.ACTION_DOWN;
48 keyEventChannel.sendFlutterKeyEvent(
49 flutterEvent,
50 isKeyUp,
51 (isEventHandled) -> onKeyEventHandledCallback.onKeyEventHandled(isEventHandled));
52 }
void sendFlutterKeyEvent( @NonNull FlutterKeyEvent keyEvent, boolean isKeyUp, @NonNull EventResponseHandler responseHandler)

The documentation for this class was generated from the following file: