diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/viewport.cpp | 14 | ||||
-rw-r--r-- | scene/main/viewport.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index e580e64db6..712ad4f1ea 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2033,6 +2033,17 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } } +void Viewport::_gui_cleanup_internal_state(Ref<InputEvent> p_event) { + ERR_FAIL_COND(p_event.is_null()); + + Ref<InputEventMouseButton> mb = p_event; + if (mb.is_valid()) { + if (!mb->is_pressed()) { + gui.mouse_focus_mask &= ~mouse_button_to_mask(mb->get_button_index()); // Remove from mask. + } + } +} + List<Control *>::Element *Viewport::_gui_add_root_control(Control *p_control) { gui.roots_order_dirty = true; return gui.roots.push_back(p_control); @@ -2695,6 +2706,9 @@ void Viewport::push_input(const Ref<InputEvent> &p_event, bool p_local_coords) { if (!is_input_handled()) { _gui_input_event(ev); + } else { + // Cleanup internal GUI state after accepting event during _input(). + _gui_cleanup_internal_state(ev); } event_count++; diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 1976b20502..e4912f31c5 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -388,6 +388,7 @@ private: Control *_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform, Transform2D &r_inv_xform); void _gui_input_event(Ref<InputEvent> p_event); + void _gui_cleanup_internal_state(Ref<InputEvent> p_event); _FORCE_INLINE_ Transform2D _get_input_pre_xform() const; |