diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index d80ccbd9a00..2a59bbc3fb1 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -82,8 +82,15 @@ void EditorLog::_clear_request() { } void EditorLog::_copy_request() { + String text = log->get_selected_text(); - log->selection_copy(); + if (text == "") { + text = log->get_text(); + } + + if (text != "") { + OS::get_singleton()->set_clipboard(text); + } } void EditorLog::clear() { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 21cfa410eb1..0c1a7b13fa4 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2578,10 +2578,10 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p return false; } -void RichTextLabel::selection_copy() { - - if (!selection.active || !selection.enabled) - return; +String RichTextLabel::get_selected_text() { + if (!selection.active || !selection.enabled) { + return ""; + } String text; @@ -2611,6 +2611,12 @@ void RichTextLabel::selection_copy() { item = _get_next_item(item, true); } + return text; +} + +void RichTextLabel::selection_copy() { + String text = get_selected_text(); + if (text != "") { OS::get_singleton()->set_clipboard(text); } diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 618ab4351be..179bb37b40b 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -473,6 +473,7 @@ public: void set_selection_enabled(bool p_enabled); bool is_selection_enabled() const; + String get_selected_text(); void selection_copy(); Error parse_bbcode(const String &p_bbcode);