-Fix mouse coordinates not being affected by canvas transform
This commit is contained in:
parent
6d63dda72b
commit
bdfac2806f
1 changed files with 8 additions and 5 deletions
|
@ -1516,7 +1516,8 @@ Control* Viewport::_gui_find_control(const Point2& p_global) {
|
|||
CanvasItem *pci = sw->get_parent_item();
|
||||
if (pci)
|
||||
xform=pci->get_global_transform_with_canvas();
|
||||
|
||||
else
|
||||
xform=sw->get_canvas_transform();
|
||||
|
||||
Control *ret = _gui_find_control_at_pos(sw,p_global,xform,gui.focus_inv_xform);
|
||||
if (ret)
|
||||
|
@ -1535,6 +1536,8 @@ Control* Viewport::_gui_find_control(const Point2& p_global) {
|
|||
CanvasItem *pci = sw->get_parent_item();
|
||||
if (pci)
|
||||
xform=pci->get_global_transform_with_canvas();
|
||||
else
|
||||
xform=sw->get_canvas_transform();
|
||||
|
||||
|
||||
Control *ret = _gui_find_control_at_pos(sw,p_global,xform,gui.focus_inv_xform);
|
||||
|
@ -1654,7 +1657,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
|
|||
|
||||
|
||||
|
||||
Matrix32 parent_xform;
|
||||
//Matrix32 parent_xform;
|
||||
|
||||
//if (data.parent_canvas_item)
|
||||
// parent_xform=data.parent_canvas_item->get_global_transform();
|
||||
|
@ -2207,7 +2210,7 @@ void Viewport::_gui_grab_click_focus(Control *p_control) {
|
|||
|
||||
//send unclic
|
||||
|
||||
Point2 click =gui.mouse_focus->get_global_transform().affine_inverse().xform(gui.last_mouse_pos);
|
||||
Point2 click =gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
|
||||
mb.x=click.x;
|
||||
mb.y=click.y;
|
||||
mb.button_index=gui.mouse_focus_button;
|
||||
|
@ -2216,8 +2219,8 @@ void Viewport::_gui_grab_click_focus(Control *p_control) {
|
|||
|
||||
|
||||
gui.mouse_focus=p_control;
|
||||
gui.focus_inv_xform=gui.mouse_focus->get_global_transform().affine_inverse();
|
||||
click =gui.mouse_focus->get_global_transform().affine_inverse().xform(gui.last_mouse_pos);
|
||||
gui.focus_inv_xform=gui.mouse_focus->get_global_transform_with_canvas().affine_inverse();
|
||||
click =gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
|
||||
mb.x=click.x;
|
||||
mb.y=click.y;
|
||||
mb.button_index=gui.mouse_focus_button;
|
||||
|
|
Loading…
Reference in a new issue