Material Box

Material Box

WEB Design & Material Images

Godot - Enabling Context Menu in a RichTextLabel

Godot

This code example shows how to enable the context menu in a RichTextLabel using GDScript.


You can enable the context menu for a RichTextLabel by setting the `context_menu_enabled` property to `true`.
The default value of the `context_menu_enabled` property is `false`.
The context menu provides the user with options to "Copy" and "Select All".
You also need to set the `selection_enabled` property to `true` to allow the user to select text.

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

# Enable text selection in RichTextLabel
label.selection_enabled = true

# Enable context menu in RichTextLabel
label.context_menu_enabled = true

Godot

TitleGodot - Enabling Context Menu in a RichTextLabel

CategoryGodot

Created

Update

AuthorYousuke.U