diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-27 11:22:13 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-06-27 11:22:13 -0300 |
commit | 88e28af5e360d826ee0e83944dff0003375e3daf (patch) | |
tree | ea6a696d16afda66c488f4866f44c39d2d2703e2 | |
parent | d41b7a66e9e01b55310d68e216139d6b6cc712f1 (diff) |
Add a small workaround to avoid modal tabs to be closed if they are spawned in the same frame, closes #3837
-rw-r--r-- | scene/gui/control.cpp | 7 | ||||
-rw-r--r-- | scene/gui/control.h | 2 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 3 |
3 files changed, 11 insertions, 1 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 8f96fbbafc..fc27c0d24f 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -762,6 +762,11 @@ bool Control::is_window_modal_on_top() const { return get_viewport()->_gui_is_modal_on_top(this); } +uint64_t Control::get_modal_frame() const { + + return data.modal_frame; +} + Size2 Control::get_minimum_size() const { @@ -1837,6 +1842,7 @@ void Control::show_modal(bool p_exclusive) { raise(); data.modal_exclusive=p_exclusive; data.MI=get_viewport()->_gui_show_modal(this); + data.modal_frame=OS::get_singleton()->get_frames_drawn(); } @@ -2547,6 +2553,7 @@ Control::Control() { data.parent_canvas_item=NULL; data.scale=Vector2(1,1); data.drag_owner=0; + data.modal_frame=0; for (int i=0;i<4;i++) { diff --git a/scene/gui/control.h b/scene/gui/control.h index 07a28de1ea..830ebd1620 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -132,6 +132,7 @@ private: ObjectID drag_owner; bool modal; bool modal_exclusive; + uint64_t modal_frame; //frame used to put something as modal Ref<Theme> theme; Control *theme_owner; String tooltip; @@ -249,6 +250,7 @@ public: Size2 get_custom_minimum_size() const; bool is_window_modal_on_top() const; + uint64_t get_modal_frame() const; //frame in which this was made modal Control *get_parent_control() const; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 76af81c325..f09fac6c71 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1752,8 +1752,9 @@ void Viewport::_gui_input_event(InputEvent p_event) { Vector2 pos = top->get_global_transform_with_canvas().affine_inverse().xform(mpos); if (!top->has_point(pos)) { - if (top->data.modal_exclusive) { + if (top->data.modal_exclusive || top->data.modal_frame==OS::get_singleton()->get_frames_drawn()) { //cancel event, sorry, modal exclusive EATS UP ALL + //alternative, you can't pop out a window the same frame it was made modal (fixes many issues) //get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID); get_tree()->set_input_as_handled(); return; // no one gets the event if exclusive NO ONE |