@@ -47,7 +47,7 @@ void AcceptDialog::_input_from_window(const Ref<InputEvent> &p_event) {
4747}
4848
4949void AcceptDialog::_parent_focused () {
50- if (!is_exclusive () && get_flag (FLAG_POPUP)) {
50+ if (popped_up && !is_exclusive () && get_flag (FLAG_POPUP)) {
5151 _cancel_pressed ();
5252 }
5353}
@@ -71,13 +71,22 @@ void AcceptDialog::_notification(int p_what) {
7171 parent_visible->connect (SceneStringName (focus_entered), callable_mp (this , &AcceptDialog::_parent_focused));
7272 }
7373 } else {
74+ popped_up = false ;
7475 if (parent_visible) {
7576 parent_visible->disconnect (SceneStringName (focus_entered), callable_mp (this , &AcceptDialog::_parent_focused));
7677 parent_visible = nullptr ;
7778 }
7879 }
7980 } break ;
8081
82+ case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
83+ if (!is_in_edited_scene_root ()) {
84+ if (has_focus ()) {
85+ popped_up = true ;
86+ }
87+ }
88+ } break ;
89+
8190 case NOTIFICATION_THEME_CHANGED: {
8291 bg_panel->add_theme_style_override (" panel" , theme_cache.panel_style );
8392
@@ -114,8 +123,14 @@ void AcceptDialog::_text_submitted(const String &p_text) {
114123 _ok_pressed ();
115124}
116125
126+ void AcceptDialog::_post_popup () {
127+ Window::_post_popup ();
128+ popped_up = true ;
129+ }
130+
117131void AcceptDialog::_ok_pressed () {
118132 if (hide_on_ok) {
133+ popped_up = false ;
119134 set_visible (false );
120135 }
121136 ok_pressed ();
@@ -124,6 +139,7 @@ void AcceptDialog::_ok_pressed() {
124139}
125140
126141void AcceptDialog::_cancel_pressed () {
142+ popped_up = false ;
127143 Window *parent_window = parent_visible;
128144 if (parent_visible) {
129145 parent_visible->disconnect (SceneStringName (focus_entered), callable_mp (this , &AcceptDialog::_parent_focused));
0 commit comments