Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Attributes | List of all members
io.flutter.embedding.android.KeyboardManager Class Reference
Inheritance diagram for io.flutter.embedding.android.KeyboardManager:

Classes

class  CharacterCombiner
 
interface  Responder
 
interface  ViewDelegate
 

Public Member Functions

 KeyboardManager (@NonNull ViewDelegate viewDelegate)
 
boolean handleEvent (@NonNull KeyEvent keyEvent)
 
void destroy ()
 
Map< Long, Long > getKeyboardState ()
 

Protected Attributes

final Responder[] responders
 

Detailed Description

Processes keyboard events and cooperate with TextInputPlugin.

Flutter uses asynchronous event handling to avoid blocking the UI thread, but Android requires that events are handled synchronously. So when the Android system sends newlink KeyEvent} to Flutter, Flutter responds synchronously that the key has been handled so that it won't propagate to other components. It then uses "delayed event synthesis", where it sends the event to the framework, and if the framework responds that it has not handled the event, then this class synthesizes a new event to send to Android, without handling it this time.

Flutter processes an Android KeyEvent with several components, each can choose whether to handled the event, and only unhandled events can move to the next section.

Definition at line 45 of file KeyboardManager.java.

Constructor & Destructor Documentation

◆ KeyboardManager()

io.flutter.embedding.android.KeyboardManager.KeyboardManager ( @NonNull ViewDelegate  viewDelegate)
inline

Construct a KeyboardManager.

Parameters
viewDelegateprovides a set of interfaces that the keyboard manager needs to interact with other components and the platform, and is typically implements by FlutterView.

Definition at line 118 of file KeyboardManager.java.

118 {
119 this.viewDelegate = viewDelegate;
120 this.responders =
121 new Responder[] {
122 new KeyEmbedderResponder(viewDelegate.getBinaryMessenger()),
123 new KeyChannelResponder(new KeyEventChannel(viewDelegate.getBinaryMessenger())),
124 };
125 final KeyboardChannel keyboardChannel = new KeyboardChannel(viewDelegate.getBinaryMessenger());
126 keyboardChannel.setKeyboardMethodHandler(this);
127 }

Member Function Documentation

◆ destroy()

void io.flutter.embedding.android.KeyboardManager.destroy ( )
inline

Definition at line 238 of file KeyboardManager.java.

238 {
239 final int remainingRedispatchCount = redispatchedEvents.size();
240 if (remainingRedispatchCount > 0) {
241 Log.w(
242 TAG,
243 "A KeyboardManager was destroyed with "
244 + String.valueOf(remainingRedispatchCount)
245 + " unhandled redispatch event(s).");
246 }
247 }
void Log(const char *format,...) SK_PRINTF_LIKE(1

◆ getKeyboardState()

Map< Long, Long > io.flutter.embedding.android.KeyboardManager.getKeyboardState ( )
inline

Returns an unmodifiable view of the pressed state.

Returns
A map whose keys are physical keyboard key IDs and values are the corresponding logical keyboard key IDs.

Definition at line 267 of file KeyboardManager.java.

267 {
268 KeyEmbedderResponder embedderResponder = (KeyEmbedderResponder) responders[0];
269 return embedderResponder.getPressedState();
270 }

◆ handleEvent()

boolean io.flutter.embedding.android.KeyboardManager.handleEvent ( @NonNull KeyEvent  keyEvent)
inline

Definition at line 220 of file KeyboardManager.java.

220 {
221 final boolean isRedispatchedEvent = redispatchedEvents.remove(keyEvent);
222 if (isRedispatchedEvent) {
223 return false;
224 }
225
226 if (responders.length > 0) {
227 final PerEventCallbackBuilder callbackBuilder = new PerEventCallbackBuilder(keyEvent);
228 for (final Responder primaryResponder : responders) {
229 primaryResponder.handleEvent(keyEvent, callbackBuilder.buildCallback());
230 }
231 } else {
232 onUnhandled(keyEvent);
233 }
234
235 return true;
236 }

Member Data Documentation

◆ responders

final Responder [] io.flutter.embedding.android.KeyboardManager.responders
protected

Definition at line 215 of file KeyboardManager.java.


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