Improvement for the Copy button in the Output Log

Now if no text is selected, pressing the Copy button copies the entire text.

(cherry picked from commit fb6eb21afc)
This commit is contained in:
Danil Alexeev 2020-09-14 21:14:27 +03:00 committed by Rémi Verschelde
parent 880ab559ec
commit 44bdd8f16c
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 19 additions and 5 deletions

View File

@ -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() {

View File

@ -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);
}

View File

@ -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);