diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 2448db6b7fb..db72c5ac9b1 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2821,7 +2821,10 @@ void RichTextLabel::gui_input(const Ref &p_event) { handled = true; } if (k->is_action("ui_copy", true)) { - selection_copy(); + const String txt = get_selected_text(); + if (!txt.is_empty()) { + DisplayServer::get_singleton()->clipboard_set(txt); + } handled = true; } } @@ -6634,14 +6637,6 @@ void RichTextLabel::deselect() { queue_redraw(); } -void RichTextLabel::selection_copy() { - String txt = get_selected_text(); - - if (!txt.is_empty()) { - DisplayServer::get_singleton()->clipboard_set(txt); - } -} - void RichTextLabel::select_all() { _validate_line_caches(); @@ -7618,7 +7613,14 @@ Key RichTextLabel::_get_menu_action_accelerator(const String &p_action) { void RichTextLabel::menu_option(int p_option) { switch (p_option) { case MENU_COPY: { - selection_copy(); + String txt = get_selected_text(); + if (txt.is_empty()) { + txt = get_parsed_text(); + } + + if (!txt.is_empty()) { + DisplayServer::get_singleton()->clipboard_set(txt); + } } break; case MENU_SELECT_ALL: { select_all(); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index b66767c6de4..156e972b365 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -866,7 +866,6 @@ public: float get_selection_line_offset() const; String get_selected_text() const; void select_all(); - void selection_copy(); _FORCE_INLINE_ void set_selection_modifier(const Callable &p_modifier) { selection_modifier = p_modifier;