mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
GUI: Copy all text in RichTextLabel if nothing is selected
This commit is contained in:
parent
428a762e98
commit
decf5bf865
2 changed files with 12 additions and 11 deletions
|
|
@ -2821,7 +2821,10 @@ void RichTextLabel::gui_input(const Ref<InputEvent> &p_event) {
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
if (k->is_action("ui_copy", true)) {
|
if (k->is_action("ui_copy", true)) {
|
||||||
selection_copy();
|
const String txt = get_selected_text();
|
||||||
|
if (!txt.is_empty()) {
|
||||||
|
DisplayServer::get_singleton()->clipboard_set(txt);
|
||||||
|
}
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6634,14 +6637,6 @@ void RichTextLabel::deselect() {
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RichTextLabel::selection_copy() {
|
|
||||||
String txt = get_selected_text();
|
|
||||||
|
|
||||||
if (!txt.is_empty()) {
|
|
||||||
DisplayServer::get_singleton()->clipboard_set(txt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RichTextLabel::select_all() {
|
void RichTextLabel::select_all() {
|
||||||
_validate_line_caches();
|
_validate_line_caches();
|
||||||
|
|
||||||
|
|
@ -7618,7 +7613,14 @@ Key RichTextLabel::_get_menu_action_accelerator(const String &p_action) {
|
||||||
void RichTextLabel::menu_option(int p_option) {
|
void RichTextLabel::menu_option(int p_option) {
|
||||||
switch (p_option) {
|
switch (p_option) {
|
||||||
case MENU_COPY: {
|
case MENU_COPY: {
|
||||||
selection_copy();
|
String txt = get_selected_text();
|
||||||
|
if (txt.is_empty()) {
|
||||||
|
txt = get_parsed_text();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!txt.is_empty()) {
|
||||||
|
DisplayServer::get_singleton()->clipboard_set(txt);
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case MENU_SELECT_ALL: {
|
case MENU_SELECT_ALL: {
|
||||||
select_all();
|
select_all();
|
||||||
|
|
|
||||||
|
|
@ -866,7 +866,6 @@ public:
|
||||||
float get_selection_line_offset() const;
|
float get_selection_line_offset() const;
|
||||||
String get_selected_text() const;
|
String get_selected_text() const;
|
||||||
void select_all();
|
void select_all();
|
||||||
void selection_copy();
|
|
||||||
|
|
||||||
_FORCE_INLINE_ void set_selection_modifier(const Callable &p_modifier) {
|
_FORCE_INLINE_ void set_selection_modifier(const Callable &p_modifier) {
|
||||||
selection_modifier = p_modifier;
|
selection_modifier = p_modifier;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue