Is there an easy way to disable events for the top...
# compose
y
Is there an easy way to disable events for the top layer of Box. I essentially want a debug only overlay, that doesn't stop the events being handled in the normal UI below.
Copy code
Box {
  Content()
  Overlay(modifier = Modifier.ignoreTouchEvents())
}
a
Modifier.pointerInput(Unit) { detectTapGestures {} }
should work.
y
Nope, it's still detecting events. My overlay has a scrolling list, do I need to disable at all levels?
a
I’m confused. Do you want to disable the touch of
Content()
or
Overlay()
?
that doesn’t stop the events being handled in the normal UI below
You mean “does stop” right?
y
The overlay is purely for information, I want the buttons and events in Content() to be handled as normal.
I'm trying a few random things at the moment, zindex modifier, and if I can't get that working I'll draw it as a canvas. But I was hoping there was a simple way to have a tranparent overlay that does consumer and recat to events.
a
Ok I see what you mean. But I’m not sure why you can’t just remove the modifiers that handle touch events in the overlay.
y
I don't have any modifiers that handle touch events, they are there as part of the components I'm using to render the overlay, for example a scrolling list.
a
That's what I mean. Inside the overlay.
y
OK, I'll try that. Thanks.
v
you can have a state to keep track of like enabling/showing the overlay layer and toggle that state according to your need , if I am getting you right
y
No, was more about having a transparent debug overlay that didn't handle events. I got it working using a Canvas as the top layer. It doesn't intercept the events, so the control in the content layer still work.
👌 1
Think Frame Rate or Jank Stats draw on top of the app, but not clickable.
z
You could use a popup that has touch input disabled. Compose’s popup api doesn’t support disabling touch events yet but should be trivial to plumb that flag through
But this has come up a number of times in this slack. I don’t see a feature request for it yet though, filing
How do you want your overlay to be handled by accessibility services? You might also want to clear semantics actions in the overlay.
y
Thanks, in this case it's purely a debug utility, so I'd like it ignored from A11y, but not too worried if not.