From 68c6a609fe781c67eaf0ca155da878c00ff45479 Mon Sep 17 00:00:00 2001 From: Chris Fairclough Date: Thu, 30 Jan 2020 13:28:54 +0000 Subject: [PATCH] add a drag threshold so right clicks are better distinguished from right drags especially on large screens --- Scripts/Editor/NodeEditorAction.cs | 8 ++++++-- Scripts/Editor/NodeEditorWindow.cs | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 8021a16..e3cf227 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -32,6 +32,7 @@ namespace XNodeEditor { private Rect selectionBox; private bool isDoubleClick = false; private Vector2 lastMousePosition; + private float dragThreshold = 1f; public void Controls() { wantsMouseMove = true; @@ -134,8 +135,11 @@ namespace XNodeEditor { Repaint(); } } else if (e.button == 1 || e.button == 2) { - panOffset += e.delta * zoom; - isPanning = true; + //check drag threshold for larger screens + if (e.delta.magnitude > dragThreshold) { + panOffset += e.delta * zoom; + isPanning = true; + } } break; case EventType.MouseDown: diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 1f64653..ec68331 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -78,6 +78,8 @@ namespace XNodeEditor { current = this; ValidateGraphEditor(); if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); + + dragThreshold = Screen.width / 1000f; } [InitializeOnLoadMethod]