Hey folks! Does anybody know if there’s a way to d...
# compose
d
Hey folks! Does anybody know if there’s a way to detect any user interaction (taps/clicks anywhere on the screen) within a Compose app? I tried using a container Composable with
pointerInput
, but that only works when I interact outside of buttons. Basically, what I need is a Compose version of the
onUserInteraction()
Activity callback.
c
Oooh. I did something like this (in order to show a "debug" only menu) but i dont think it gets every interaction (like if theres a button then my callback isn't called). I don't think I did anything fancy, it was just a composable that surrounded my App() composable with a clickable listener and I update a touch counter value and if it hits 3 (triple click) then I showed the secret menu, and every 500ms it would reset the counter down to 0.
d
Yeah, that’s what I had tried as well. But as you’ve mentioned, the callback doesn’t get called when interacting with buttons 😞
c
I think that's what you'd want though? like you dont want some parent clickable to intercept the deeper children clicks? But in this case... I don't think you necessarily care about clicks, you just want to know if something was tapped? That has to be possible, but yeah idk how to do it. Sorry!
d
Yeah. I just need to know if the user interacted with the app in any way. For know I'm using the activity callback, but I wanted to handle it in a “compose way”.
1
z
Make sure you're using the Initial pass, otherwise the leaf input handlers will consume. • Initial: top-down • Main: bottom-up • Final: top-down
m
if it hits 3 (triple click) then I showed the secret menu, and every 500ms it would reset the counter down to 0.
I prefer a "code" of tapping the app icon and app name in the correct sequence on the About screen 😄
c
What's cool about our "debug drawer" is that we have contextual actions. different actions for a different screen. stolen from jake whartons u2020 project. 🙃