Is there any support for popups or tooltips from A...
# compose
r
Is there any support for popups or tooltips from AnnotatedString, or from text in general? For Desktop, specifically, but it seems like it would be a general compose API and thus more appropriate here. I looked into rolling my own, but the closest thing I could find is SelectionHandle & related things, but most of it relies on private stuff.
j
Sounds like you're saying there are some APIs that are unnecessarily taking in String instead of AnnotatedString or Composable Lambda, right? Can you be a little more specific by specifying exactly which composable functions (full signature) you're looking at?
r
Not really, or at least not as far as I'm aware of. I'm trying to show a popup when a user hovers over or clicks on a region of (annotated) text, like a link showing it's address on hover. Afaik there's no way to do that even if the popup I want is a pure string. I can use ClickableText to handle the clicks just fine, but there's no way to translate the character offset into a positional offset for the popup.
SelectionHandle
and friends look like they do something similar to what I want, but only for selection. I looked at copying and modifying them, but they use enough private/internal APIs that doesn't seem possible.
j
Ah, got it. Yeah, I don't think there is any built-in tooltip support yet, but you should be able to implement such a thing in user land, and feel free to contribute it to upstream or publish it for others to use. To display some content above other content, I would look into:
androidx.compose.ui.window.Popup(...)
And to measure the text so you can know how/where to position the popup, take a look at this thread: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1610401037448100