How do I make a Composable transparent for clicks? I want my Composable to "disappear" both visually and for click events, so that the user is able to click some content below my Composable. But my Composable should still be counted in size calculations, kinda like INVISIBLE in View system.
Any ideas how to make clicks pass though my Composable?
j
james
03/03/2023, 6:14 AM
build your clickable modifier conditionally. something like this:
Copy code
val modifier = Modifier
.fillMaxWidth()
.graphicsLayer { alpha = if (invisible) 0f else 1f }
val maybeClickableModifier = if (invisible) {
modifier
} else {
modifier.clickable { /* your click event */ }
}
a
alaershov
03/03/2023, 6:29 AM
this would probably work if my Composable didn't have any clickable children. However, it does, and their clickable modifiers still work. I want the whole container to disappear and become transparent for clicks
j
james
03/03/2023, 6:37 AM
ah gotcha
in that case you want to again have a conditional modifier (or custom modifier) on the parent, and using pointerInput you can consume the events before any children get the chance
james
03/03/2023, 6:38 AM
1 sec, I’ll see if I can find specifics for you. I’ve seen it mentioned before