This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
shell/platform/android/io/flutter/view Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121import android .util .AttributeSet ;
2222import android .util .SparseArray ;
2323import android .view .DisplayCutout ;
24+ import android .view .KeyEvent ;
2425import android .view .MotionEvent ;
2526import android .view .PointerIcon ;
2627import android .view .Surface ;
@@ -267,6 +268,23 @@ public DartExecutor getDartExecutor() {
267268 return dartExecutor ;
268269 }
269270
271+ @ Override
272+ public boolean dispatchKeyEvent (KeyEvent event ) {
273+ Log .e (TAG , "dispatchKeyEvent: " + event .toString ());
274+ if (event .getAction () == KeyEvent .ACTION_DOWN && event .getRepeatCount () == 0 ) {
275+ // Tell Android to start tracking this event.
276+ getKeyDispatcherState ().startTracking (event , this );
277+ } else if (event .getAction () == KeyEvent .ACTION_UP ) {
278+ // Stop tracking the event.
279+ getKeyDispatcherState ().handleUpEvent (event );
280+ }
281+ // If the key processor doesn't handle it, then send it on to the
282+ // superclass. The key processor will typically handle all events except
283+ // those where it has re-dispatched the event after receiving a reply from
284+ // the framework that the framework did not handle it.
285+ return (isAttached () && androidKeyProcessor .onKeyEvent (event )) || super .dispatchKeyEvent (event );
286+ }
287+
270288 public FlutterNativeView getFlutterNativeView () {
271289 return mNativeView ;
272290 }
You can’t perform that action at this time.
0 commit comments