Skip to content

Commit decf5bf

Browse files
committed
GUI: Copy all text in RichTextLabel if nothing is selected
1 parent 428a762 commit decf5bf

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

scene/gui/rich_text_label.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,10 @@ void RichTextLabel::gui_input(const Ref<InputEvent> &p_event) {
28212821
handled = true;
28222822
}
28232823
if (k->is_action("ui_copy", true)) {
2824-
selection_copy();
2824+
const String txt = get_selected_text();
2825+
if (!txt.is_empty()) {
2826+
DisplayServer::get_singleton()->clipboard_set(txt);
2827+
}
28252828
handled = true;
28262829
}
28272830
}
@@ -6634,14 +6637,6 @@ void RichTextLabel::deselect() {
66346637
queue_redraw();
66356638
}
66366639

6637-
void RichTextLabel::selection_copy() {
6638-
String txt = get_selected_text();
6639-
6640-
if (!txt.is_empty()) {
6641-
DisplayServer::get_singleton()->clipboard_set(txt);
6642-
}
6643-
}
6644-
66456640
void RichTextLabel::select_all() {
66466641
_validate_line_caches();
66476642

@@ -7618,7 +7613,14 @@ Key RichTextLabel::_get_menu_action_accelerator(const String &p_action) {
76187613
void RichTextLabel::menu_option(int p_option) {
76197614
switch (p_option) {
76207615
case MENU_COPY: {
7621-
selection_copy();
7616+
String txt = get_selected_text();
7617+
if (txt.is_empty()) {
7618+
txt = get_parsed_text();
7619+
}
7620+
7621+
if (!txt.is_empty()) {
7622+
DisplayServer::get_singleton()->clipboard_set(txt);
7623+
}
76227624
} break;
76237625
case MENU_SELECT_ALL: {
76247626
select_all();

scene/gui/rich_text_label.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,6 @@ class RichTextLabel : public Control {
866866
float get_selection_line_offset() const;
867867
String get_selected_text() const;
868868
void select_all();
869-
void selection_copy();
870869

871870
_FORCE_INLINE_ void set_selection_modifier(const Callable &p_modifier) {
872871
selection_modifier = p_modifier;

0 commit comments

Comments
 (0)