Skip to content

Commit

Permalink
Fix global position for InputEventMouse in viewport::push_input
Browse files Browse the repository at this point in the history
Global position doesn't get adjusted within `InputEventMouse::xformed_by()`.
  • Loading branch information
Sauermann committed Feb 18, 2024
1 parent 8f0c20e commit 8de3991
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,13 @@ Ref<InputEvent> Viewport::_make_input_local(const Ref<InputEvent> &ev) {
}

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);
}

Expand Down

0 comments on commit 8de3991

Please sign in to comment.