diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 2d608195eb4..07cb77ae15a 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2051,6 +2051,11 @@ void Control::show_modal(bool p_exclusive) { data.modal_frame = Engine::get_singleton()->get_frames_drawn(); } +void Control::set_modal_exclusive(bool p_exclusive) { + ERR_FAIL_NULL_MSG(data.MI, "Modal exclusive can be set only if the Control is already shown as modal."); + data.modal_exclusive = p_exclusive; +} + void Control::_modal_set_prev_focus_owner(ObjectID p_prev) { data.modal_prev_focus_owner = p_prev; } diff --git a/scene/gui/control.h b/scene/gui/control.h index 41dbfe49c3f..0a0d33665cc 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -250,6 +250,7 @@ protected: virtual void remove_child_notify(Node *p_child); //virtual void _window_gui_input(InputEvent p_event); + void set_modal_exclusive(bool p_exclusive); bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 13afd25c4ea..6845041ad19 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -194,6 +194,9 @@ void Popup::_popup(const Rect2 &p_bounds, const bool p_centered) { void Popup::set_exclusive(bool p_exclusive) { exclusive = p_exclusive; + if (popped_up) { + set_modal_exclusive(exclusive); + } } bool Popup::is_exclusive() const {