summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-09-24 15:18:59 +0200
committerGitHub <noreply@github.com>2020-09-24 15:18:59 +0200
commit915ac7360a70904a4ee4294fd8b53ce2c757ee95 (patch)
treeb57cc019e03c920a2b6ca007f88bc227f748eecb /scene/gui
parent3e4627ab6f450ae08bfa9a3bd792990d548169b1 (diff)
parentfb6eb21afc0a98b2b1439268abb0facd53222a43 (diff)
Merge pull request #42066 from dalexeev/output_copy
Improvement for the Copy button in the Output Log
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/rich_text_label.cpp10
-rw-r--r--scene/gui/rich_text_label.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index fb4931ea91..e8acac172c 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -2529,9 +2529,9 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
return false;
}
-void RichTextLabel::selection_copy() {
+String RichTextLabel::get_selected_text() {
if (!selection.active || !selection.enabled) {
- return;
+ return "";
}
String text;
@@ -2561,6 +2561,12 @@ void RichTextLabel::selection_copy() {
item = _get_next_item(item, true);
}
+ return text;
+}
+
+void RichTextLabel::selection_copy() {
+ String text = get_selected_text();
+
if (text != "") {
DisplayServer::get_singleton()->clipboard_set(text);
}
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 2bda7c7fce..c5ed1cb3ef 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -475,6 +475,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);