https://kotlinlang.org logo
#compose
Title
# compose
n

Noé Casas

02/03/2021, 4:36 PM
It is possible to have something like the
.clickable
modifier but with information of the position where the user clicked?
b

Bryan Herbst

02/03/2021, 4:39 PM
You should be able to get that from
InteractionState
. Here’s how
Ripple
gets the press position to place the Ripple correctly: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]ompose/material/ripple/Ripple.kt;l=177-181?q=rippleindication
l

Louis Pullen-Freilich [G]

02/03/2021, 4:51 PM
Note that the InteractionState API will likely be changing soon, but also that it is intended for the use case of building components / indication that reacts to states. If you are building your own component and not a generic indication, you can use
Modifier.pointerInput
instead, with
detectTapGestures
n

Noé Casas

02/03/2021, 7:11 PM
Thanks a lot. I ended up using
InteractionState
because it was clearer to me how to use it.
2 Views