This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree 1 file changed +18
-0
lines changed
shell/platform/android/io/flutter/view 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 21
21
import android .util .AttributeSet ;
22
22
import android .util .SparseArray ;
23
23
import android .view .DisplayCutout ;
24
+ import android .view .KeyEvent ;
24
25
import android .view .MotionEvent ;
25
26
import android .view .PointerIcon ;
26
27
import android .view .Surface ;
@@ -267,6 +268,23 @@ public DartExecutor getDartExecutor() {
267
268
return dartExecutor ;
268
269
}
269
270
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
+
270
288
public FlutterNativeView getFlutterNativeView () {
271
289
return mNativeView ;
272
290
}
You can’t perform that action at this time.
0 commit comments