From 72b31aafc4449f7b6838c3be7527bc3fe287ac49 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 15 Nov 2019 19:34:44 +0100 Subject: Make holding Ctrl toggle snapping in GraphEdit This affects the visual script and visual shader editors as well. --- scene/gui/graph_edit.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 7827c66841..ed9fc0ce51 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -819,8 +819,11 @@ void GraphEdit::_gui_input(const Ref &p_ev) { if (gn && gn->is_selected()) { Vector2 pos = (gn->get_drag_from() * zoom + drag_accum) / zoom; - if (is_using_snap()) { - int snap = get_snap(); + + // Snapping can be toggled temporarily by holding down Ctrl. + // This is done here as to not toggle the grid when holding down Ctrl. + if (is_using_snap() ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { + const int snap = get_snap(); pos = pos.snapped(Vector2(snap, snap)); } -- cgit v1.2.3