|
@@ -1889,6 +1889,10 @@ void TextEdit::_notification(int p_what) {
|
|
|
if (OS::get_singleton()->has_virtual_keyboard() && virtual_keyboard_enabled) {
|
|
|
OS::get_singleton()->hide_virtual_keyboard();
|
|
|
}
|
|
|
+
|
|
|
+ if (deselect_on_focus_loss_enabled) {
|
|
|
+ deselect();
|
|
|
+ }
|
|
|
} break;
|
|
|
case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
|
|
|
if (has_focus()) {
|
|
@@ -1916,6 +1920,8 @@ void TextEdit::_notification(int p_what) {
|
|
|
selection.active = false;
|
|
|
selection.selecting_mode = Selection::MODE_NONE;
|
|
|
update();
|
|
|
+ } else if (deselect_on_focus_loss_enabled) {
|
|
|
+ deselect();
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -7307,6 +7313,17 @@ bool TextEdit::is_selecting_enabled() const {
|
|
|
return selecting_enabled;
|
|
|
}
|
|
|
|
|
|
+void TextEdit::set_deselect_on_focus_loss_enabled(const bool p_enabled) {
|
|
|
+ deselect_on_focus_loss_enabled = p_enabled;
|
|
|
+ if (p_enabled && selection.active && !has_focus()) {
|
|
|
+ deselect();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+bool TextEdit::is_deselect_on_focus_loss_enabled() const {
|
|
|
+ return deselect_on_focus_loss_enabled;
|
|
|
+}
|
|
|
+
|
|
|
bool TextEdit::is_shortcut_keys_enabled() const {
|
|
|
return shortcut_keys_enabled;
|
|
|
}
|
|
@@ -7415,6 +7432,8 @@ void TextEdit::_bind_methods() {
|
|
|
ClassDB::bind_method(D_METHOD("is_virtual_keyboard_enabled"), &TextEdit::is_virtual_keyboard_enabled);
|
|
|
ClassDB::bind_method(D_METHOD("set_selecting_enabled", "enable"), &TextEdit::set_selecting_enabled);
|
|
|
ClassDB::bind_method(D_METHOD("is_selecting_enabled"), &TextEdit::is_selecting_enabled);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_deselect_on_focus_loss_enabled", "enable"), &TextEdit::set_deselect_on_focus_loss_enabled);
|
|
|
+ ClassDB::bind_method(D_METHOD("is_deselect_on_focus_loss_enabled"), &TextEdit::is_deselect_on_focus_loss_enabled);
|
|
|
ClassDB::bind_method(D_METHOD("is_line_set_as_safe", "line"), &TextEdit::is_line_set_as_safe);
|
|
|
ClassDB::bind_method(D_METHOD("set_line_as_safe", "line", "safe"), &TextEdit::set_line_as_safe);
|
|
|
ClassDB::bind_method(D_METHOD("is_line_set_as_bookmark", "line"), &TextEdit::is_line_set_as_bookmark);
|
|
@@ -7527,6 +7546,7 @@ void TextEdit::_bind_methods() {
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shortcut_keys_enabled"), "set_shortcut_keys_enabled", "is_shortcut_keys_enabled");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "virtual_keyboard_enabled"), "set_virtual_keyboard_enabled", "is_virtual_keyboard_enabled");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selecting_enabled"), "set_selecting_enabled", "is_selecting_enabled");
|
|
|
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deselect_on_focus_loss_enabled"), "set_deselect_on_focus_loss_enabled", "is_deselect_on_focus_loss_enabled");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_scroll_speed"), "set_v_scroll_speed", "get_v_scroll_speed");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hiding_enabled"), "set_hiding_enabled", "is_hiding_enabled");
|
|
@@ -7692,6 +7712,7 @@ TextEdit::TextEdit() {
|
|
|
minimap_line_spacing = 1;
|
|
|
|
|
|
selecting_enabled = true;
|
|
|
+ deselect_on_focus_loss_enabled = true;
|
|
|
context_menu_enabled = true;
|
|
|
shortcut_keys_enabled = true;
|
|
|
menu = memnew(PopupMenu);
|