Material Box

Material Box

WEBデザイン & フリー素材

Godot - RichTextLabelでコンテキストメニューを有効にする

Godot

GDScriptでRichTextLabelでコンテキストメニューを有効にする方法とコード例です。


「context_menu_enabled」プロパティを「true」に変更する事でRichTextLabelでコンテキストメニューを有効にします。
「context_menu_enabled」プロパティのデフォルト値は「false」です。
コンテキストメニューでは、ユーザー操作による「コピー」と「すべて選択」が利用可能です。
また、ユーザーがテキストを選択可能にしておくために「selection_enabled」プロパティを「true」に変更します。

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

# RichTextLabelでテキストの選択を有効にする
label.selection_enabled = true

# RichTextLabelでコンテキストメニューを有効にする
label.context_menu_enabled = true

Godot

TitleGodot - RichTextLabelでコンテキストメニューを有効にする

CategoryGodot

Created

Update

AuthorYousuke.U