listener? I want to override onBackPressed to make sure I don't navigate back in certain cases
g
Grigorii Yurkov
10/31/2020, 3:42 PM
Modifier.keyInputFilter
a
Adam Powell
10/31/2020, 3:46 PM
Key input is subject to various key event dispatch and focus rules that can cause the events to be missed. The androidx OnBackPressedDispatcher is the preferred way of doing it these days; if you poke around the jet* samples you can see a few copy/pastes of basically this gist: https://gist.github.com/adamp/62d13fe5bf0d6ddf9fcf58f8a6769523
👌 1
Adam Powell
10/31/2020, 3:46 PM
the style in there is a bit dated but you get the idea 🙂 use
Providers
up near your initial
setContent
or whatnot to provide the OnBackPressedDispatcherOwner and you're good to go
s
Se7eN
10/31/2020, 4:20 PM
Got it. Thanks!
Se7eN
10/31/2020, 5:11 PM
AmbientBackPressedDispatcher
isn't supposed to be private right?
a
Adam Powell
10/31/2020, 7:20 PM
Up to you. I pulled this out of an app I was writing where it was in the same file I was providing it from 🙂