From 8de39911c8e4f628d585dc5c1c6af66bfbfb3720 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Sun, 18 Feb 2024 02:49:48 +0100 Subject: [PATCH] Fix global position for `InputEventMouse` in `viewport::push_input` Global position doesn't get adjusted within `InputEventMouse::xformed_by()`. --- scene/main/viewport.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index da72c8b737d..a86a685fc31 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1383,6 +1383,13 @@ Ref Viewport::_make_input_local(const Ref &ev) { } Transform2D ai = get_final_transform().affine_inverse(); + Ref me = ev; + if (me.is_valid()) { + me = me->xformed_by(ai); + // For InputEventMouse, the global position is not adjusted by ev->xformed_by() and needs to be set separately. + me->set_global_position(me->get_position()); + return me; + } return ev->xformed_by(ai); }