summaryrefslogtreecommitdiff
path: root/scene/2d/canvas_item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/canvas_item.cpp')
-rw-r--r--scene/2d/canvas_item.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index fa9b040d92..eb37634b24 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -1003,11 +1003,14 @@ InputEvent CanvasItem::make_input_local(const InputEvent& p_event) const {
Vector2 CanvasItem::get_global_mouse_pos() const {
- return get_viewport_transform().affine_inverse().xform(Input::get_singleton()->get_mouse_pos());
+ ERR_FAIL_COND_V(!get_viewport(),Vector2());
+ return get_canvas_transform().affine_inverse().xform( get_viewport()->get_mouse_pos() );
}
Vector2 CanvasItem::get_local_mouse_pos() const{
- return (get_viewport_transform() * get_global_transform()).affine_inverse().xform(Input::get_singleton()->get_mouse_pos());
+ ERR_FAIL_COND_V(!get_viewport(),Vector2());
+
+ return get_global_transform().affine_inverse().xform( get_global_mouse_pos() );
}