|
@@ -1068,8 +1068,7 @@ void RichTextLabel::_notification(int p_what) {
|
|
} break;
|
|
} break;
|
|
case NOTIFICATION_FOCUS_EXIT: {
|
|
case NOTIFICATION_FOCUS_EXIT: {
|
|
if (deselect_on_focus_loss_enabled) {
|
|
if (deselect_on_focus_loss_enabled) {
|
|
- selection.active = false;
|
|
|
|
- update();
|
|
|
|
|
|
+ deselect();
|
|
}
|
|
}
|
|
} break;
|
|
} break;
|
|
case Control::NOTIFICATION_DRAG_END: {
|
|
case Control::NOTIFICATION_DRAG_END: {
|
|
@@ -1177,9 +1176,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
|
|
selection.from_char = '\0';
|
|
selection.from_char = '\0';
|
|
selection.to = nullptr;
|
|
selection.to = nullptr;
|
|
selection.to_char = '\0';
|
|
selection.to_char = '\0';
|
|
- selection.active = false;
|
|
|
|
-
|
|
|
|
- update();
|
|
|
|
|
|
+ deselect();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1224,14 +1221,11 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
|
|
selection.click = item;
|
|
selection.click = item;
|
|
selection.click_char = line;
|
|
selection.click_char = line;
|
|
if (_is_click_inside_selection()) {
|
|
if (_is_click_inside_selection()) {
|
|
- selection.active = false;
|
|
|
|
selection.from = nullptr;
|
|
selection.from = nullptr;
|
|
selection.from_char = '\0';
|
|
selection.from_char = '\0';
|
|
selection.to = nullptr;
|
|
selection.to = nullptr;
|
|
selection.to_char = '\0';
|
|
selection.to_char = '\0';
|
|
- selection.active = false;
|
|
|
|
-
|
|
|
|
- update();
|
|
|
|
|
|
+ deselect();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (selection.enabled && OS::get_singleton()->has_feature("primary_clipboard")) {
|
|
if (selection.enabled && OS::get_singleton()->has_feature("primary_clipboard")) {
|
|
@@ -1367,8 +1361,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
|
|
if (selection.from_char > selection.to_char) {
|
|
if (selection.from_char > selection.to_char) {
|
|
swap = true;
|
|
swap = true;
|
|
} else if (selection.from_char == selection.to_char) {
|
|
} else if (selection.from_char == selection.to_char) {
|
|
- selection.active = false;
|
|
|
|
- update();
|
|
|
|
|
|
+ deselect();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2008,9 +2001,8 @@ void RichTextLabel::clear() {
|
|
main->lines.clear();
|
|
main->lines.clear();
|
|
main->lines.resize(1);
|
|
main->lines.resize(1);
|
|
main->first_invalid_line = 0;
|
|
main->first_invalid_line = 0;
|
|
- update();
|
|
|
|
selection.click = nullptr;
|
|
selection.click = nullptr;
|
|
- selection.active = false;
|
|
|
|
|
|
+ deselect();
|
|
current_idx = 1;
|
|
current_idx = 1;
|
|
if (scroll_follow) {
|
|
if (scroll_follow) {
|
|
scroll_following = true;
|
|
scroll_following = true;
|
|
@@ -2538,8 +2530,7 @@ void RichTextLabel::set_selection_enabled(bool p_enabled) {
|
|
selection.enabled = p_enabled;
|
|
selection.enabled = p_enabled;
|
|
if (!p_enabled) {
|
|
if (!p_enabled) {
|
|
if (selection.active) {
|
|
if (selection.active) {
|
|
- selection.active = false;
|
|
|
|
- update();
|
|
|
|
|
|
+ deselect();
|
|
}
|
|
}
|
|
set_focus_mode(FOCUS_NONE);
|
|
set_focus_mode(FOCUS_NONE);
|
|
} else {
|
|
} else {
|
|
@@ -2550,8 +2541,7 @@ void RichTextLabel::set_selection_enabled(bool p_enabled) {
|
|
void RichTextLabel::set_deselect_on_focus_loss_enabled(const bool p_enabled) {
|
|
void RichTextLabel::set_deselect_on_focus_loss_enabled(const bool p_enabled) {
|
|
deselect_on_focus_loss_enabled = p_enabled;
|
|
deselect_on_focus_loss_enabled = p_enabled;
|
|
if (p_enabled && selection.active && !has_focus()) {
|
|
if (p_enabled && selection.active && !has_focus()) {
|
|
- selection.active = false;
|
|
|
|
- update();
|
|
|
|
|
|
+ deselect();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2670,6 +2660,11 @@ String RichTextLabel::get_selected_text() {
|
|
return text;
|
|
return text;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void RichTextLabel::deselect() {
|
|
|
|
+ selection.active = false;
|
|
|
|
+ update();
|
|
|
|
+}
|
|
|
|
+
|
|
void RichTextLabel::selection_copy() {
|
|
void RichTextLabel::selection_copy() {
|
|
String text = get_selected_text();
|
|
String text = get_selected_text();
|
|
|
|
|
|
@@ -2820,6 +2815,7 @@ void RichTextLabel::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("pop"), &RichTextLabel::pop);
|
|
ClassDB::bind_method(D_METHOD("pop"), &RichTextLabel::pop);
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("clear"), &RichTextLabel::clear);
|
|
ClassDB::bind_method(D_METHOD("clear"), &RichTextLabel::clear);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("deselect"), &RichTextLabel::deselect);
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_meta_underline", "enable"), &RichTextLabel::set_meta_underline);
|
|
ClassDB::bind_method(D_METHOD("set_meta_underline", "enable"), &RichTextLabel::set_meta_underline);
|
|
ClassDB::bind_method(D_METHOD("is_meta_underlined"), &RichTextLabel::is_meta_underlined);
|
|
ClassDB::bind_method(D_METHOD("is_meta_underlined"), &RichTextLabel::is_meta_underlined);
|