Hey you awesome folks,. Do you know if there is a...
# compose
m
Hey you awesome folks,. Do you know if there is a way to pass a click through to the Composable's parent. Now I have to specifically add that I'm not talking about event propagation via lambdas. That's easy to achieve but since this is an SDK question essentially I'm trying to avoid it due to complicating the composable in question and introducing a breaking change. I have an annotated string and only the links should be clickable, the rest of the text should not capture clicks but gracefully let the parent composable handle them. Now this is tricky because this is done via
Modifier.pointerInput()
which still has to make the whole Composable area clickable and then decide when it should treat it as a clickable link on a per section basis. I'm wondering if there is any way in compose to say yup point
x=1, y=1
should be treated as a click on the
Text
Composable but point
x=2, y=2
should be treated as a click on its parent. Unsure if this is doable, but if it is it will allow me to implement a really clean and easy to use solution. šŸ˜„ Thank you!
šŸ‘ 1
c
I asked about this recently, but never got a response. From what I found, the events themselves do automatically propagate through the UI tree for many of the "input" modifiers, it's just that
pointerInput
automatically "consumes" all events it intercepts, which causes the parent elements to ignore it. I couldn't find an easy way to get around that, unfortunately https://kotlinlang.slack.com/archives/CJLTWPH7S/p1643302597237200
m
This is great information Casey, thank you. If my hands are tied then I'll resort to lambdas as something is better than nothing.
b
Were you able to find a solution to this? I just ran into something very similar
c
I haven't seen anything official, but in the latest version of my string-formatting library, Thistle, I've added a workaround, a fallback click handler which gets called when a click doesn't hit a region of linked text. I haven't fully tested or documented the fix yet, which is why I haven't posted it generally, but you can see the example usage here