diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-05-17 12:56:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 12:56:53 +0200 |
commit | ccdd85d8e709e27a173fff9bc314cc4e31240d7b (patch) | |
tree | e87bab9db5640fff09b42593821b853f6da182b3 /scene/gui | |
parent | 129767da7063ffb6a4e0d592d478b51b0be0be1b (diff) | |
parent | 47d0dc8a410f9a69f40db6ce0f65b8493a78d3a4 (diff) |
Merge pull request #61001 from derammo/derammo_popup_conditional_hide
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(); |