Material Box

Material Box

WEB Design & Material Images

Godot - Enabling Text Selection in a RichTextLabel

Godot

This code example shows how to enable users to select text in a RichTextLabel using GDScript.


You can enable text selection for the text displayed in a RichTextLabel by setting the `selection_enabled` property to `true`.
The default value of the `selection_enabled` property is `false`.
After selection, keyboard shortcuts for copying are available, but the device's context menu or text selection menu cannot be displayed, so you need to implement a separate process for copying to the clipboard.

var label = RichTextLabel.new()
add_child(label)
label.global_position = Vector2(0, 0)
label.size = Vector2(200,200)
label.text = "Text Selection"

# Enable text selection in RichTextLabel
label.selection_enabled = true

Godot

TitleGodot - Enabling Text Selection in a RichTextLabel

CategoryGodot

Created

Update

AuthorYousuke.U