bosskmk / pluto_grid

PlutoGrid is a dataGrid for flutter that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS.
https://pluto.weblaze.dev
MIT License
635 stars 288 forks source link

Bubble up key events incl. shortcuts that are not handled by PlutoGrid #1070

Open AdamDreessen opened 2 weeks ago

AdamDreessen commented 2 weeks ago

PlutoGridState registers its own key handler _handleGridFocusKeyOnly via the FocusScope widget and onKeyEvent property. The registered key handler always returns KeyEventResult.handled. This prevents parent widgets to use own shortcuts because key events are not "bubbled up" in the widget hierarchy.

Pluto Grid defines its own "default actions" and "shortcuts". It is desirable that only these are prevented from "bubbling up" and all other key events are passed on to parent widgets.

With this PR we implemented this behavior in PlutoGridState._handleGridFocusOnKey.

AdamDreessen commented 1 week ago

@KaushikGupta007

Will this fix back button not working issue in Android

I cannot tell but might be worth a try. We're using it in a Win/MacOS desktop app. And without this fix we are not able to handle key events (e.g. global shortcuts on app level) outside the PlutoGrid.

AdamDreessen commented 1 week ago

@KaushikGupta007 I just tested the sample app from your bug report: https://github.com/bosskmk/pluto_grid/issues/1066 And yes, this PR here fixes it. The Android back button works.

KaushikGupta007 commented 1 week ago

@AdamDreessen Yeah, thanks for the fix. I hope it gets merged soon.