From f4640af9c17c2a1d5d0c3e83ecaea7d6aea93ecb Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Mon, 8 Jun 2020 12:23:30 -0400 Subject: [PATCH] [3.2][macOS] Control key + scroll wheel should zoom not pan Fixes godotengine/godot#32520 --- editor/plugins/canvas_item_editor_plugin.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 10a495f1f89..cf0c658a5ea 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1302,6 +1302,18 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref &p_event, bo Ref pan_gesture = p_event; if (pan_gesture.is_valid() && !p_already_accepted) { + // If control key pressed, then zoom instead of pan + if (pan_gesture->get_control()) { + const float factor = pan_gesture->get_delta().y; + float new_zoom = _get_next_zoom_value(-1); + + if (factor != 1.f) { + new_zoom = zoom * ((new_zoom / zoom - 1.f) * factor + 1.f); + } + _zoom_on_position(new_zoom, pan_gesture->get_position()); + return true; + } + // Pan gesture const Vector2 delta = (int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom) * pan_gesture->get_delta(); view_offset.x += delta.x;