Note: this is very similar to this unanswered question, but that question is mixing events (onTap
and onLongPress
) and I don't know if that makes a difference or not.
I can react on tap events on an object with .pointerInput
and detectTapGestures
. With nested composables, the tap is consumed by the innermost child.
For example, if I nest a Box
inside another Box
, like so:
Box(
modifier = Modifier
.pointerInput(Unit) {
detectTapGestures(onTap = {
println("TAP in parent Box")
})
}
) {
Box(
modifier = Modifier
.pointerInput(Unit) {
detectTapGestures(onTap = {
println("TAP in child Box")
})
}
) {}
}
Then tapping the box will result in the innermost callback being triggered, showing "TAP in child Box".
How could I intercept the tap in the parent Box
? And is there a way to not consume it, such that it goes through to the child?