Hi everyone , Ive been using the TextField with Li...
# compose
j
Hi everyone , Ive been using the TextField with LinkAnnotation but the callback doesn’t work. Is there any work around ?
z
Can you share some code? And define “doesn’t work”?
j
I forgot to mention that “doesn’t work” means that the callback doesn’t work and it takes the selection change from the state as primary action.
z
You just said doesn’t work again. I’m not trying to be a jerk, it’s just that there are many ways something can “not work” and so it’s more helpful to specifically describe what you’re doing and observing. How are you activating the link (tap or accessibility service?) Can you reproduce the bug in a small sample that you can share? What version of compose are you using?
j
I will share some code
See this part of the code
Copy code
pushStringAnnotation(id, text)
if (child.marks.any { it is LinkMark }) {
    withLink(
        link = LinkAnnotation.Url(
            url = child.marks.filterIsInstance<LinkMark>().first().attrs.href,
            styles = TextLinkStyles(child.createStyle()),
            linkInteractionListener = {
                val url = (it as LinkAnnotation.Url).url
                onUrlClicked?.invoke(url)
            }
        )
    ) {
        append(text)
    }
} else {
    append(text)
    addStyle(
        style = child.createStyle(),
        start = child.start,
        end = child.end
    )
}
pop()
I'm creating an annotatedString
z
And your `linkInteractionListener`'s not getting invoked when you tap on the link?
j
That's right, seems to be that it's not intercepting the callback when using a BasicTextField.
z
I don't think link annotations are supported on text fields yet, @Halil Ozercan can confirm
😮 2
h
LinkAnnotations are not supported on both flavors of TextField,
TextFieldValue
and
TextFieldState
.
🥲 1