Skip to content

Commit

Permalink
Merge pull request #39993 from reduz/make-dialogs-exclusive
Browse files Browse the repository at this point in the history
Make dialogs exclusive by default, fixes #37732
  • Loading branch information
akien-mga authored Jun 30, 2020
2 parents 84e9e58 + b19ab94 commit 73262c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scene/gui/dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions scene/gui/dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class LineEdit;
class AcceptDialog : public Window {
GDCLASS(AcceptDialog, Window);

public:
Window *parent_visible;
Panel *bg;
HBoxContainer *hbc;
Expand Down
12 changes: 12 additions & 0 deletions scene/main/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 73262c0

Please sign in to comment.