From a3e933cf4fb2cdd9d3021038f5f991c4da14e13a Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 9 Feb 2022 16:14:16 +0200 Subject: [PATCH] Fix a bug where the selection got stuck to the canvas boundaries when they were 1px away from them --- src/UI/Canvas/Selection.gd | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/UI/Canvas/Selection.gd b/src/UI/Canvas/Selection.gd index db418abcb..07ca28c32 100644 --- a/src/UI/Canvas/Selection.gd +++ b/src/UI/Canvas/Selection.gd @@ -192,7 +192,14 @@ func _move_with_arrow_keys(event: InputEvent) -> void: var input := Vector2() input.x = int(event.is_action("ui_right")) - int(event.is_action("ui_left")) input.y = int(event.is_action("ui_down")) - int(event.is_action("ui_up")) - move_content(input.rotated(stepify(Global.camera.rotation, PI / 2)) * step) + var move := input.rotated(stepify(Global.camera.rotation, PI / 2)) + # These checks are needed to fix a bug where the selection boundaries + # got stuck to the canvas boundaries when they were 1px away from them + if is_equal_approx(abs(move.x), 0): + move.x = 0 + if is_equal_approx(abs(move.y), 0): + move.y = 0 + move_content(move * step) # Check if an event is a ui_up/down/left/right event-press