Allow changing `exclusive` of already popped up Popup

This commit is contained in:
kleonc 2022-05-28 01:10:48 +02:00
parent 53843de558
commit 9ba598f94f
3 changed files with 9 additions and 0 deletions

View File

@ -2051,6 +2051,11 @@ void Control::show_modal(bool p_exclusive) {
data.modal_frame = Engine::get_singleton()->get_frames_drawn(); 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) { void Control::_modal_set_prev_focus_owner(ObjectID p_prev) {
data.modal_prev_focus_owner = p_prev; data.modal_prev_focus_owner = p_prev;
} }

View File

@ -250,6 +250,7 @@ protected:
virtual void remove_child_notify(Node *p_child); virtual void remove_child_notify(Node *p_child);
//virtual void _window_gui_input(InputEvent p_event); //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 _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const; bool _get(const StringName &p_name, Variant &r_ret) const;

View File

@ -194,6 +194,9 @@ void Popup::_popup(const Rect2 &p_bounds, const bool p_centered) {
void Popup::set_exclusive(bool p_exclusive) { void Popup::set_exclusive(bool p_exclusive) {
exclusive = p_exclusive; exclusive = p_exclusive;
if (popped_up) {
set_modal_exclusive(exclusive);
}
} }
bool Popup::is_exclusive() const { bool Popup::is_exclusive() const {