Improvement for the Copy button in the Output Log

Now if no text is selected, pressing the Copy button copies the entire text.
This commit is contained in:
Danil Alexeev 2020-09-14 21:14:27 +03:00
parent c5f7a581f7
commit fb6eb21afc
3 changed files with 18 additions and 3 deletions

View File

@ -79,7 +79,15 @@ void EditorLog::_clear_request() {
} }
void EditorLog::_copy_request() { void EditorLog::_copy_request() {
log->selection_copy(); String text = log->get_selected_text();
if (text == "") {
text = log->get_text();
}
if (text != "") {
DisplayServer::get_singleton()->clipboard_set(text);
}
} }
void EditorLog::clear() { void EditorLog::clear() {

View File

@ -2529,9 +2529,9 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
return false; return false;
} }
void RichTextLabel::selection_copy() { String RichTextLabel::get_selected_text() {
if (!selection.active || !selection.enabled) { if (!selection.active || !selection.enabled) {
return; return "";
} }
String text; String text;
@ -2561,6 +2561,12 @@ void RichTextLabel::selection_copy() {
item = _get_next_item(item, true); item = _get_next_item(item, true);
} }
return text;
}
void RichTextLabel::selection_copy() {
String text = get_selected_text();
if (text != "") { if (text != "") {
DisplayServer::get_singleton()->clipboard_set(text); DisplayServer::get_singleton()->clipboard_set(text);
} }

View File

@ -475,6 +475,7 @@ public:
void set_selection_enabled(bool p_enabled); void set_selection_enabled(bool p_enabled);
bool is_selection_enabled() const; bool is_selection_enabled() const;
String get_selected_text();
void selection_copy(); void selection_copy();
Error parse_bbcode(const String &p_bbcode); Error parse_bbcode(const String &p_bbcode);