diff options
author | derammo <817160+derammo@users.noreply.github.com> | 2022-05-13 08:22:29 -0400 |
---|---|---|
committer | derammo <817160+derammo@users.noreply.github.com> | 2022-05-13 09:30:00 -0400 |
commit | 47d0dc8a410f9a69f40db6ce0f65b8493a78d3a4 (patch) | |
tree | 2ed2897a285b974c584c8e7a240dae51e435b63b /scene/gui | |
parent | 677b63d7656fd0f11e224e0858fcf9479486595d (diff) |
popup deferred hide suppressed if reopened
popup no longer tries to close itself a second time
popup no longer closes after having been reopened
fixed bug in RenameDialog not calling base (by inspection)
fixes #59181
fixes #60921
reverts #59287
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/popup.cpp | 16 | ||||
-rw-r--r-- | scene/gui/popup.h | 4 |
2 files changed, 19 insertions, 1 deletions
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index b9e3e7814e..6532fc5934 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -108,11 +108,25 @@ void Popup::_close_pressed() { _deinitialize_visible_parents(); - call_deferred(SNAME("hide")); + // Hide after returning to process events, but only if we don't + // get popped up in the interim. + call_deferred(SNAME("_popup_conditional_hide")); +} + +void Popup::_post_popup() { + Window::_post_popup(); + popped_up = true; +} + +void Popup::_popup_conditional_hide() { + if (!popped_up) { + hide(); + } } void Popup::_bind_methods() { ADD_SIGNAL(MethodInfo("popup_hide")); + ClassDB::bind_method(D_METHOD("_popup_conditional_hide"), &Popup::_popup_conditional_hide); } Rect2i Popup::_popup_adjust_rect() const { diff --git a/scene/gui/popup.h b/scene/gui/popup.h index 6211af4d20..27f46d4a97 100644 --- a/scene/gui/popup.h +++ b/scene/gui/popup.h @@ -57,6 +57,10 @@ protected: void _notification(int p_what); static void _bind_methods(); + void _popup_conditional_hide(); + + virtual void _post_popup() override; + public: Popup(); ~Popup(); |