mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 22:23:07 +00:00
Add a small workaround to avoid modal tabs to be closed if they are spawned in the same frame, closes #3837
This commit is contained in:
parent
d41b7a66e9
commit
88e28af5e3
@ -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++) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user