summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-03-14 10:12:10 +0100
committerGitHub <noreply@github.com>2022-03-14 10:12:10 +0100
commit2347c6bce3330c96ca59369460b6c5c18198f6c2 (patch)
tree0c538d723391f867f2ecfd0f8c6faff78326bdd9
parentb7bc8dbebe6cbf303ef27edf48565e23bf9933b5 (diff)
parent86574b91dd4dfb8931f4810e20096302965d2d30 (diff)
Merge pull request #59129 from Sauermann/fix-internal-gui-state
-rw-r--r--scene/main/viewport.cpp14
-rw-r--r--scene/main/viewport.h1
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;