Make dialogs exclusive by default, fixes #37732
Also fix on set_visible, not creating exclusive children as it should.
This commit is contained in:
parent
84e9e58084
commit
b19ab945ac
@ -51,8 +51,10 @@ void AcceptDialog::_input_from_window(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
|
||||
void AcceptDialog::_parent_focused() {
|
||||
if (!is_exclusive()) {
|
||||
_cancel_pressed();
|
||||
}
|
||||
}
|
||||
|
||||
void AcceptDialog::_notification(int p_what) {
|
||||
switch (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);
|
||||
|
@ -44,6 +44,7 @@ class LineEdit;
|
||||
class AcceptDialog : public Window {
|
||||
GDCLASS(AcceptDialog, Window);
|
||||
|
||||
public:
|
||||
Window *parent_visible;
|
||||
Panel *bg;
|
||||
HBoxContainer *hbc;
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user