diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-11-16 09:34:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 09:34:28 +0100 |
commit | 94875f5f481d17fce4db68b44ecd657afbe9d66e (patch) | |
tree | e89c85d453c70ac44ad2b30cd70e8986dabc8604 /scene/gui/popup.cpp | |
parent | d7176e9040c6db885dace95a942bcc2c6889e15b (diff) | |
parent | c482e8ec85e75f8900c11ba04213c3e42fd64db6 (diff) | |
download | redot-engine-94875f5f481d17fce4db68b44ecd657afbe9d66e.tar.gz |
Merge pull request #41851 from EricEzaM/PR/popup-menu-hysteresis
Added hysteresis for popup sub-menus
Diffstat (limited to 'scene/gui/popup.cpp')
-rw-r--r-- | scene/gui/popup.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 49ddd5c3ee..791c78e2b4 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -93,7 +93,7 @@ void Popup::_notification(int p_what) { } void Popup::_parent_focused() { - if (popped_up) { + if (popped_up && close_on_parent_focus) { _close_pressed(); } } @@ -112,7 +112,19 @@ void Popup::set_as_minsize() { set_size(get_contents_minimum_size()); } +void Popup::set_close_on_parent_focus(bool p_close) { + close_on_parent_focus = p_close; +} + +bool Popup::get_close_on_parent_focus() { + return close_on_parent_focus; +} + void Popup::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_close_on_parent_focus", "close"), &Popup::set_close_on_parent_focus); + ClassDB::bind_method(D_METHOD("get_close_on_parent_focus"), &Popup::get_close_on_parent_focus); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "close_on_parent_focus"), "set_close_on_parent_focus", "get_close_on_parent_focus"); + ADD_SIGNAL(MethodInfo("popup_hide")); } |