I'm trying to render text with links. I'm currentl...
# compose
m
I'm trying to render text with links. I'm currently using
AnnotatedString
with
LinkAnnotation
, and this works fine for styling and clicking the links. But my links also need right-click context menus (which can be different for each link), and
LinkAnnotation
does not have a right-click interaction listener. What would be the correct way to implement this? I need to know that a link was right-clicked, and need to know the coordinates so that I can draw the context menu at that place.
j
You might be able to achieve that with
appendInlineContent
But not sure if that is the right way or whether its comfortable to implement.
a
You could do this with a combination of
Modifier.onTextLayout
and
Modifier.onPointerInput
. The first will let you find binding boxes for your linked text. The second will give the offsets on right click. Check whether the offset lies inside the bounding boxes and show a context menu at the offset.
🙌 1
👍 1
h
please file a feature request 🙂
this is a good idea and the API should support it.
m
@Aditya Bhaskar Thank you, I used that approach and it worked.
👍🏽 1