https://kotlinlang.org logo
a

Adib Faramarzi

07/06/2021, 3:47 AM
How would you go for finger "hover" detection? I have a grid of boxes and I want the user to hold their finger and drag onto the boxes, all the boxes that have been touched by the finger should be notified.
The problem is if I handle the touch event inside one box, it would get eaten by that box and no one else will be notified.
I was thinking of an API (modifier) that would allow me to determine if a composable contains a point in screen. Or Simple put, gives me it's bounding box (position and width and height).
a

Albert Chang

07/06/2021, 4:13 AM
Modifier.onGloballyPositioned()
a

Adib Faramarzi

07/06/2021, 4:30 AM
I'm not sure if the second approach is best though, I'm aiming to create a modifier like
onHover {}
a

Albert Chang

07/06/2021, 4:33 AM
You can try but I don’t think handling a single gesture in multiple places makes sense.
a

Adib Faramarzi

07/12/2021, 3:56 AM
It's not handling, that's the point. It's about notification of it
2 Views