diff options
author | Juan Linietsky <reduzio@gmail.com> | 2020-06-30 14:01:10 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-06-30 14:02:37 -0300 |
commit | b19ab945acec594a17e8a11cec53eec17ad4c4a5 (patch) | |
tree | 1659295371b6022a7ade300b01e9f4aae09ab96c | |
parent | 84e9e58084d12771d04cd2ece16b32720867fcbd (diff) |
Make dialogs exclusive by default, fixes #37732
Also fix on set_visible, not creating exclusive children as it should.
-rw-r--r-- | scene/gui/dialogs.cpp | 5 | ||||
-rw-r--r-- | scene/gui/dialogs.h | 1 | ||||
-rw-r--r-- | scene/main/window.cpp | 12 |
3 files changed, 17 insertions, 1 deletions
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index c6897fc684..bacc65c7bf 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -51,7 +51,9 @@ void AcceptDialog::_input_from_window(const Ref<InputEvent> &p_event) { } void AcceptDialog::_parent_focused() { - _cancel_pressed(); + if (!is_exclusive()) { + _cancel_pressed(); + } } void AcceptDialog::_notification(int p_what) { @@ -295,6 +297,7 @@ AcceptDialog::AcceptDialog() { set_wrap_controls(true); set_visible(false); set_transient(true); + set_exclusive(true); bg = memnew(Panel); add_child(bg); diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h index 5d7b6272bf..81664733a3 100644 --- a/scene/gui/dialogs.h +++ b/scene/gui/dialogs.h @@ -44,6 +44,7 @@ class LineEdit; class AcceptDialog : public Window { GDCLASS(AcceptDialog, Window); +public: Window *parent_visible; Panel *bg; HBoxContainer *hbc; diff --git a/scene/main/window.cpp b/scene/main/window.cpp index da02f932f1..7f2160c6a5 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -398,6 +398,18 @@ void Window::set_visible(bool p_visible) { emit_signal(SceneStringNames::get_singleton()->visibility_changed); RS::get_singleton()->viewport_set_active(get_viewport_rid(), visible); + + //update transient exclusive + if (transient_parent) { + if (exclusive && visible) { + ERR_FAIL_COND_MSG(transient_parent->exclusive_child && transient_parent->exclusive_child != this, "Transient parent has another exclusive child."); + transient_parent->exclusive_child = this; + } else { + if (transient_parent->exclusive_child == this) { + transient_parent->exclusive_child = nullptr; + } + } + } } void Window::_clear_transient() { |