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

andrew

03/11/2022, 11:16 PM
Quick technical question, is there any reason why clickable events being propagated through a box will travel through elements until it reaches a clickable? I.e. my touches seem to phase through views that are above another. This has probably been answered, but figured I’d ask
Here's an example, you can see touches pass through the Debug View
c

Casey Brooks

03/11/2022, 11:33 PM
Boxes and other basic layouts do not intercept clicks by default, it would be very counterintuitive if they did. If you don't have any "input" modifiers on the debug card to intercept the click, then you should expect that it would not block clicks on the content beneath it.
a

andrew

03/11/2022, 11:37 PM
Gotcha, that makes sense why something like surface has clickAndSemanticModifier internally underneath
c

Casey Brooks

03/11/2022, 11:40 PM
Consider that in Compose is designed to handle deeply nested layouts, and that there's really nothing special to a layout at all; it doesn't define any colors, interactions, or even clipping by itself. All that stuff that might be more tighly coupled to layouts in other UI toolkits are all done through Modifiers. And that's precisely where Surface, Card, and other more specialized "layouts" come into the picture. But those are all just built upon the same primitive layouts and Modifiers, and still don't really mean anything special in themselves other than the opinionated use of layouts/modifiers
a

andrew

03/11/2022, 11:41 PM
Yeah, I guess I’m just used to a few things being done for me as a given, I just needed to know where to tailor my expectations a bit as to what get’s handled where and the proper way to do things
2 Views