I have a full-screen scrollable overlay and I'm tr...
# compose
v
I have a full-screen scrollable overlay and I'm trying to prevent touch input from accidentally going into the background content when the overlay is visible. I tried to do this by applying a modifier to the overlay parent container, but this seems to interfere with the scrollability of the overlay inner content. There probably is a better approach, but I'm not sure what it would be 🤔 Or am I using
awaitPointerEvent
wrong?
Copy code
.pointerInput(Unit) {
    awaitPointerEventScope {
        while (true) { awaitPointerEvent(PointerEventPass.Main).changes.forEach { it.consume() } }
    }
}
✅ 1
a
You should use
PointetEventPass.Final
so that you only consume events that are not consumed by any child.
Also I think
Surface
already does this so you can probably just use a
Surface
as the container.
v
Oh, thanks! I will try Final next. I apparently misunderstood the differences between the event passes
Final
didn't work either blob thinking upside down It still breaks the children's scrolling.
I took a look at the
Surface
implementation. Turns out it is just an empty block:
Copy code
.pointerInput(Unit) {}
This works for my use case. Thanks for the suggestion of taking a look at Surface!
Do you know if there is some resource or documentation explaining low level pointerInput scope handling in detail? It seems quite confusing and I'd like to get to know it better
âž• 1