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

Hamba

11/21/2023, 4:52 PM
is there a way have detecttapgesture not consume the tap? i want to detect where exactly on an element a tap was made but also want the tap to go through to be detected by something underneath. alternatively, is there a way to retransmit a new tap to the element underneath instead?
a

Albert Chang

11/22/2023, 2:02 AM
The bits needed are all there and you can easily write your own version:
Copy code
suspend fun PointerInputScope.detectTapGesturesWithoutConsuming(
    onTap: (Offset) -> Unit
) {
    awaitEachGesture {
        awaitFirstDown(requireUnconsumed = false)
        val upOrCancel = waitForUpOrCancellation(PointerEventPass.Initial)
        if (upOrCancel != null) {
            onTap(upOrCancel.position)
        }
    }
}
1
h

Hamba

11/22/2023, 2:16 AM
thanks, i had something along those lines but with a lot more fluff based on some post i read. didnt realise it could be made much more simple