Fix global position for `InputEventMouse` in `viewport::push_input`

Global position doesn't get adjusted within `InputEventMouse::xformed_by()`.

(cherry picked from commit 8de39911c8)
This commit is contained in:
Markus Sauermann 2024-02-18 02:49:48 +01:00 committed by Rémi Verschelde
parent 1281517746
commit 5dfaec5c29
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 7 additions and 0 deletions

View File

@ -1344,6 +1344,13 @@ Ref<InputEvent> Viewport::_make_input_local(const Ref<InputEvent> &ev) {
} }
Transform2D ai = get_final_transform().affine_inverse(); Transform2D ai = get_final_transform().affine_inverse();
Ref<InputEventMouse> 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); return ev->xformed_by(ai);
} }