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

Ashu

01/26/2022, 2:13 PM
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.
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()
            }
        }
    }
s

saket

04/01/2022, 3:31 PM
pose
119 Views