timrijckaert
12/02/2022, 11:22 AMComposable
.
Box(
modifier = Modifier
.size(100.dp)
.background(Color.Blue)
.clickable {
// parent click listener
Timber.d("parent click")
}
) {
Box(
modifier = Modifier
.size(50.dp)
.background(Color.Red)
) {
// children
}
// ...
}
When clicking on the red Box
the parent Composable
consumes the click event even though the red box is in front of it.
This looks like a weird default behavior to be. Different from the View
system....
However when the red Box
has a click listener of its own the behavior is correct and the red Box
click listener is triggered.
Is there a better way to let the red Box
consume the event without putting an explicit clickable
modifier on it?ste
12/02/2022, 5:32 PMModifier.pointerInput(Unit) { detectTapGesturs {} }
to the red boxLoney Chou
12/03/2022, 12:45 AM