natario1
07/13/2021, 7:33 PMBox(Modifier.fillMaxSize()) {
Box(Modifier.fillMaxSize().clickable { error("Yay!") })
Box(Modifier.fillMaxSize().pointerInput(Unit) {})
}
I mean, even if parent Box decides that the second child should get events first (which is questionable, but okay), why does pointerInput
block the flow?Kirill Grouchnikov
07/13/2021, 7:41 PMnatario1
07/13/2021, 7:51 PMawaitPointerEventScope
inside pointerInput, collect them in a loop and then consume all PointerInputChanges.
See for example:
Box(Modifier.fillMaxSize().clickable { error("Yay!") }) {
Box(Modifier.fillMaxSize().pointerInput(Unit) {})
}
In this case, the child is stacked on top of the parent, and it has priority for events (great!), but since my pointerInput
implementation does not consume them, the Yay! part is reached, correctly. Issue shows up between siblings only.Andrey Kulikov
07/13/2021, 8:12 PMnatario1
07/14/2021, 8:35 AMPointerInputFilter
for a given offset, which means that the winner takes it all.
This puts a hard boundary on the event flow between sibling nodes, ignoring the fact that the winning PointerInputFilter
might not be consuming the events at all. It's a biiig difference with the View system, I hope you agree it's a bug 😄 assuming my analysis is correctmatvei
07/14/2021, 9:19 AMModalDrawer
that combines together both sliding "drawer" panel and the rest of the UI, because we have to handle the pointer input logic at the parent of both (ModalDrawer
), and not on the sliding "drawer" panel itself, otherwise the rest of the content will never receive any events.natario1
07/14/2021, 10:30 AMmatvei
07/14/2021, 11:03 AMnatario1
07/14/2021, 1:52 PMBox(Modifier.fillMaxSize()) {
Box(Modifier.fillMaxSize().pointerInput(Unit) {})
Box(Modifier.fillMaxSize().pointerInput(Unit) {})
}
In this case I have very clearly expressed my developer intent to receive (not consume) inputs in the two boxes, but I will only receive in one of them. While in this case:
Box(Modifier.fillMaxSize().pointerInput(Unit) {}) {
Box(Modifier.fillMaxSize().pointerInput(Unit) {})
}
it suddenly works. This is confusing to me.
I understand the performance gain, but I'm still not convinced 😅 not all sibling nodes have a pointerInput
(this could make the loop faster) and if they do, that's a clear signal that they want to get the events. Thanks for answering!Zach Klippenstein (he/him) [MOD]
07/14/2021, 5:53 PMmatvei
07/15/2021, 9:39 AMppvi
07/15/2021, 10:59 AMnatario1
02/03/2022, 9:10 PMshouldSharePointerInputWithSiblings
which I think did not exist at the time of the first post.matvei
02/07/2022, 6:00 AMnatario1
02/07/2022, 10:31 AMshouldSharePointerInputWithSiblings
in some hidden inner class, then I’d expect something like Modifier.pointerInput(share = true, …) maybeppvi
02/07/2022, 12:16 PMmatvei
02/07/2022, 4:59 PMPointerInputFilter
itself: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]pose/ui/input/pointer/PointerEvent.kt;l=103?q=PointerEvent.kt
This means that it is not easy to change in your regular Modifier.pointerInput
, but tit is possible if you implement your own PointerInputFilter for your custom PointerInputModifiermatvei
02/07/2022, 5:00 PMKata
08/12/2022, 6:44 AMmatvei
08/15/2022, 10:36 AMinterceptOutOfBoundsChildEvents
is not public and overridable in the PointerInputModifier
. If you really want the overlay to propogate the event to the sublings below it - you can create your own modifiers and do this.matvei
08/16/2022, 11:01 AM