This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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!

Godot version 4.0, though would welcome answers for 3.x
in Engine by (53 points)

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?

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

1 Answer

+3 votes
Best answer

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.

by (22,704 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.