From 5ab98677bd34bc204c65ce433f974013277c0046 Mon Sep 17 00:00:00 2001 From: bleeptrack Date: Tue, 27 Oct 2020 12:02:20 +0100 Subject: [PATCH] Do not open file browser on dragging commit node --- scenes/node.gd | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scenes/node.gd b/scenes/node.gd index de32a3b..6882414 100644 --- a/scenes/node.gd +++ b/scenes/node.gd @@ -12,6 +12,7 @@ var children = {} setget children_set var id_always_visible = false var held = false var hovered = false +var start_pos = null var arrow = preload("res://scenes/arrow.tscn") @@ -107,12 +108,19 @@ func _on_unhover(): func _input(event): if hovered: if event.is_action_pressed("click"): + start_pos = get_viewport().get_mouse_position() held = true - if type == "commit": - file_browser.visible = not file_browser.visible elif event.is_action_pressed("right_click"): var input = get_tree().get_current_scene().find_node("Input") input.text += id input.caret_position = input.text.length() if event.is_action_released("click"): held = false + if type == "commit": + if start_pos: + var dist = get_viewport().get_mouse_position() - start_pos + print(dist.length()) + if dist.length() < 3: + file_browser.visible = not file_browser.visible + + start_pos = null