Merge pull request #92243 from bruvzg/popup_emb_change

Fix `PopupMenu` focus issues after `Viewport::set_embedding_subwindows` is changed.
This commit is contained in:
Rémi Verschelde 2024-05-23 08:59:20 +02:00
commit 55af739d78
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 4 additions and 3 deletions

View File

@ -1014,9 +1014,6 @@ void PopupMenu::_notification(int p_what) {
float pm_delay = pm->get_submenu_popup_delay(); float pm_delay = pm->get_submenu_popup_delay();
set_submenu_popup_delay(pm_delay); set_submenu_popup_delay(pm_delay);
} }
if (!is_embedded()) {
set_flag(FLAG_NO_FOCUS, true);
}
if (system_menu_id != NativeMenu::INVALID_MENU_ID) { if (system_menu_id != NativeMenu::INVALID_MENU_ID) {
bind_global_menu(); bind_global_menu();
} }
@ -2829,6 +2826,8 @@ void PopupMenu::popup(const Rect2i &p_bounds) {
if (native) { if (native) {
NativeMenu::get_singleton()->popup(global_menu, (p_bounds != Rect2i()) ? p_bounds.position : get_position()); NativeMenu::get_singleton()->popup(global_menu, (p_bounds != Rect2i()) ? p_bounds.position : get_position());
} else { } else {
set_flag(FLAG_NO_FOCUS, !is_embedded());
moved = Vector2(); moved = Vector2();
popup_time_msec = OS::get_singleton()->get_ticks_msec(); popup_time_msec = OS::get_singleton()->get_ticks_msec();
if (!is_embedded()) { if (!is_embedded()) {
@ -2856,6 +2855,8 @@ void PopupMenu::set_visible(bool p_visible) {
NativeMenu::get_singleton()->popup(global_menu, get_position()); NativeMenu::get_singleton()->popup(global_menu, get_position());
} }
} else { } else {
set_flag(FLAG_NO_FOCUS, !is_embedded());
Popup::set_visible(p_visible); Popup::set_visible(p_visible);
} }
} }