Closed diousk closed 1 year ago
Hey, new awaitFirstDown, with Jetpack Compose 1.4.0-alpha03, takes PointerEventPass, i will update version and add this param as well
suspend fun AwaitPointerEventScope.awaitFirstDown(
requireUnconsumed: Boolean = true,
pass: PointerEventPass = PointerEventPass.Main,
): PointerInputChange {
var event: PointerEvent
do {
event = awaitPointerEvent(pass)
} while (
!event.changes.fastAll {
if (requireUnconsumed) it.changedToDown() else it.changedToDownIgnoreConsumed()
}
)
return event.changes[0]
}
May i ask in which situation you need this pass?
I'm just testing around this library and find this behavior is not expected. Some situation might be intercepting Press event at Initial pass from parent composable. Anyway, thanks for the investigation & modification.
@diousk current version now adds pass as param to awaitFirstDown and awaitPointerEvent functions. Yes, i had an issue where i needed parent below a disabled button to take action when disabled click and used Initial pass. Now, these gestures have same compatibility for any potential usecases
the current implementation of onDown() depends on awaitFirstDown(). But by default it uses PointerEventPass.Main internally. In order to interact with PointerEventPass.Initial or PointerEventPass.Final we should use the method awaitFirstDownOnPass() instead inside awaitFirstDown():
and replace awaitFirstDown() with awaitFirstDownOnPass() for onDown() callback.