Make label highlightable

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Siliwolf

I have a label. I’d like to make it so users can highlight and select it the same way you’d interact with text on a website. What’s the easiest way to do this? Thanks!

You probably want to be very explicit about what kinds of interactions you want here. Based on your website comment, I assume text selection and maybe “copy to clipboard”? No text editing, right?

What is it that you’re trying to do exactly? For instance, what’s the purpose of the user highlighting the text, assuming they can’t change it?

jgodfrey | 2023-03-10 22:45

You are correct that it’s for copying and such. It’s something where I could make it copy to clipboard on click, but I feel in my current scenario selection will be more intuitive

Siliwolf | 2023-03-10 23:15

:bust_in_silhouette: Reply From: jgodfrey

I don’t think there’s a way to (easily) select text in a Label node. However, you can do what you want with a RichTextLabel node. Just set its selection_enabled property to true. Then, you can retrieve the selected text via its get_selected_text() method.