From 7491e910f3ac689d920fbf2fa26ad3d1d909e744 Mon Sep 17 00:00:00 2001 From: Konrad Nowakowski Date: Fri, 26 Oct 2018 20:23:47 +0100 Subject: [PATCH] Fix touch release event on _gui_input --- scene/main/viewport.cpp | 7 ++++--- scene/main/viewport.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 5b1c2d80208..b220df6ce1c 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1727,6 +1727,7 @@ void Viewport::_gui_input_event(Ref p_event) { gui.mouse_focus = _gui_find_control(pos); gui.mouse_focus_mask = 1 << (mb->get_button_index() - 1); + gui.last_mouse_focus = gui.mouse_focus; if (!gui.mouse_focus) { return; @@ -2114,14 +2115,14 @@ void Viewport::_gui_input_event(Ref p_event) { set_input_as_handled(); return; } - } else if (gui.mouse_focus) { + } else if (touch_event->get_index() == 0 && gui.last_mouse_focus) { - if (gui.mouse_focus->can_process()) { + if (gui.last_mouse_focus->can_process()) { touch_event = touch_event->xformed_by(Transform2D()); //make a copy touch_event->set_position(gui.focus_inv_xform.xform(pos)); - _gui_call_input(gui.mouse_focus, touch_event); + _gui_call_input(gui.last_mouse_focus, touch_event); } set_input_as_handled(); return; diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 278350b1c90..6b6ca3b7dbf 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -271,6 +271,7 @@ private: bool key_event_accepted; Control *mouse_focus; + Control *last_mouse_focus; Control *mouse_click_grabber; int mouse_focus_mask; Control *key_focus;