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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -6634,14 +6637,6 @@ void RichTextLabel::deselect() {
|
|||
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() {
|
||||
_validate_line_caches();
|
||||
|
||||
|
|
@ -7618,7 +7613,14 @@ Key RichTextLabel::_get_menu_action_accelerator(const String &p_action) {
|
|||
void RichTextLabel::menu_option(int p_option) {
|
||||
switch (p_option) {
|
||||
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;
|
||||
case MENU_SELECT_ALL: {
|
||||
select_all();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue