diff options
| author | Juan Linietsky | 2015-02-14 19:22:06 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2015-02-14 19:22:06 -0300 |
| commit | d2f86cc09bf4136ebc1c2bbb8ec7b48a439c0371 (patch) | |
| tree | 5f9c5ffe7aec749a3d4732036f9a506d01932aa7 /scene/gui/control.cpp | |
| parent | a49802ae332e34542c0f835cce74fb3d5e49675a (diff) | |
| download | godot-d2f86cc09bf4136ebc1c2bbb8ec7b48a439c0371.tar.gz godot-d2f86cc09bf4136ebc1c2bbb8ec7b48a439c0371.tar.zst godot-d2f86cc09bf4136ebc1c2bbb8ec7b48a439c0371.zip | |
fixes to mouse warp
-can warp now from viewport and control, in their respective coordinate
systems
-warp is now local to the window on Windows and OSX.
IF YOU RUN OSX, PLEASE TEST THIS! And make sure it works!, new code is
in OS_OSX::warp_mouse_pos. I don't have OSX so i can't test!
Diffstat (limited to 'scene/gui/control.cpp')
| -rw-r--r-- | scene/gui/control.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index ce268843b..4d32c7ea9 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2688,6 +2688,12 @@ Control *Control::get_focus_owner() const { return data.window->window->key_focus; } + +void Control::warp_mouse(const Point2& p_to_pos) { + ERR_FAIL_COND(!is_inside_tree()); + get_viewport()->warp_mouse(get_global_transform().xform(p_to_pos)); +} + void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("_window_input_event"),&Control::_window_input_event); @@ -2784,6 +2790,9 @@ void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_drag_preview","control:Control"),&Control::set_drag_preview); + ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"),&Control::warp_mouse); + + BIND_VMETHOD(MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"event"))); BIND_VMETHOD(MethodInfo(Variant::VECTOR2,"get_minimum_size")); BIND_VMETHOD(MethodInfo(Variant::OBJECT,"get_drag_data",PropertyInfo(Variant::VECTOR2,"pos"))); |
