Fix Right-Click clearing selection

This commit is contained in:
ConteZero 2022-04-03 10:07:02 +02:00
parent 99c07c92eb
commit 57b616fb21
4 changed files with 10 additions and 4 deletions

View file

@ -53,6 +53,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (b.is_valid()) {
if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && context_menu_enabled) {
popup_show = true;
if (editable) {
menu->set_item_disabled(menu->get_item_index(MENU_UNDO), !has_undo());
menu->set_item_disabled(menu->get_item_index(MENU_REDO), !has_redo());
@ -62,7 +63,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
menu->set_size(Vector2(1, 1));
menu->set_scale(get_global_transform().get_scale());
menu->popup();
grab_focus();
accept_event();
return;
}
@ -608,6 +608,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
} break;
case KEY_MENU: {
if (context_menu_enabled) {
popup_show = true;
if (editable) {
menu->set_item_disabled(menu->get_item_index(MENU_UNDO), !has_undo());
menu->set_item_disabled(menu->get_item_index(MENU_REDO), !has_redo());
@ -1040,9 +1041,10 @@ void LineEdit::_notification(int p_what) {
OS::get_singleton()->hide_virtual_keyboard();
}
if (deselect_on_focus_loss_enabled) {
if (deselect_on_focus_loss_enabled && !popup_show) {
deselect();
}
popup_show = false;
} break;
case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
if (has_focus()) {

View file

@ -76,6 +76,7 @@ private:
bool selecting_enabled;
bool deselect_on_focus_loss_enabled;
bool popup_show = false;
bool context_menu_enabled;
PopupMenu *menu;

View file

@ -1897,9 +1897,10 @@ void TextEdit::_notification(int p_what) {
OS::get_singleton()->hide_virtual_keyboard();
}
if (deselect_on_focus_loss_enabled) {
if (deselect_on_focus_loss_enabled && !popup_show) {
deselect();
}
popup_show = false;
} break;
case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
if (has_focus()) {
@ -2652,6 +2653,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
popup_show = true;
if (!readonly) {
menu->set_item_disabled(menu->get_item_index(MENU_UNDO), !has_undo());
menu->set_item_disabled(menu->get_item_index(MENU_REDO), !has_redo());
@ -2661,7 +2663,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
menu->set_size(Vector2(1, 1));
menu->set_scale(get_global_transform().get_scale());
menu->popup();
grab_focus();
}
} else {
if (mb->get_button_index() == BUTTON_LEFT) {
@ -3963,6 +3964,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
case KEY_MENU: {
if (context_menu_enabled) {
popup_show = true;
if (!readonly) {
menu->set_item_disabled(menu->get_item_index(MENU_UNDO), !has_undo());
menu->set_item_disabled(menu->get_item_index(MENU_REDO), !has_redo());

View file

@ -438,6 +438,7 @@ private:
bool selecting_enabled;
bool deselect_on_focus_loss_enabled;
bool popup_show = false;
bool context_menu_enabled;
bool shortcut_keys_enabled;