diff options
Diffstat (limited to 'doc/classes/RichTextLabel.xml')
-rw-r--r-- | doc/classes/RichTextLabel.xml | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 1ecc8a1d4e..49bb65b64d 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -106,6 +106,45 @@ <return type="PopupMenu" /> <description> Returns the [PopupMenu] of this [RichTextLabel]. By default, this menu is displayed when right-clicking on the [RichTextLabel]. + You can add custom menu items or remove standard ones. Make sure your IDs don't conflict with the standard ones (see [enum MenuItems]). For example: + [codeblocks] + [gdscript] + func _ready(): + var menu = get_menu() + # Remove "Select All" item. + menu.remove_item(MENU_SELECT_ALL) + # Add custom items. + menu.add_separator() + menu.add_item("Duplicate Text", MENU_MAX + 1) + # Connect callback. + menu.id_pressed.connect(_on_item_pressed) + + func _on_item_pressed(id): + if id == MENU_MAX + 1: + add_text("\n" + get_parsed_text()) + [/gdscript] + [csharp] + public override void _Ready() + { + var menu = GetMenu(); + // Remove "Select All" item. + menu.RemoveItem(RichTextLabel.MenuItems.SelectAll); + // Add custom items. + menu.AddSeparator(); + menu.AddItem("Duplicate Text", RichTextLabel.MenuItems.Max + 1); + // Add event handler. + menu.IdPressed += OnItemPressed; + } + + public void OnItemPressed(int id) + { + if (id == TextEdit.MenuItems.Max + 1) + { + AddText("\n" + GetParsedText()); + } + } + [/csharp] + [/codeblocks] [b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their [member Window.visible] property. </description> </method> @@ -193,6 +232,13 @@ If [member threaded] is enabled, returns [code]true[/code] if the background thread has finished text processing, otherwise always return [code]true[/code]. </description> </method> + <method name="menu_option"> + <return type="void" /> + <param index="0" name="option" type="int" /> + <description> + Executes a given action as defined in the [enum MenuItems] enum. + </description> + </method> <method name="newline"> <return type="void" /> <description> @@ -633,6 +679,15 @@ </constant> <constant name="ITEM_CUSTOMFX" value="26" enum="ItemType"> </constant> + <constant name="MENU_COPY" value="0" enum="MenuItems"> + Copies the selected text. + </constant> + <constant name="MENU_SELECT_ALL" value="1" enum="MenuItems"> + Selects the whole [RichTextLabel] text. + </constant> + <constant name="MENU_MAX" value="2" enum="MenuItems"> + Represents the size of the [enum MenuItems] enum. + </constant> </constants> <theme_items> <theme_item name="default_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> |