How can I intercept click events on child composables? I have a form where I am trying to show a toast to the user if the form is not editable. So clicking on form elements which normally would trigger some form action needs to be intercepted and instead I want to show a toast to the user.
Ashu
01/26/2022, 2:15 PM
I have tried something like this but in this case all pointer events are overridden. I only wish to intercept click events and allow scroll events.
Copy code
pointerInput(Unit) {
awaitPointerEventScope {
// we should wait for all new pointer events
while (true) {
val pointerEvent = awaitPointerEvent(pass = PointerEventPass.Initial)
pointerEvent.changes
.forEach(PointerInputChange::consumeAllChanges)
onGestureEventDropped()
}
}
}