From a8daac60b0bfdb913302654730151f838cac1bc9 Mon Sep 17 00:00:00 2001 From: chrisfairc Date: Wed, 27 May 2020 07:20:20 +0100 Subject: [PATCH] Add a dragthreshold to better distunguish right clicks and right drags (#230) * add a drag threshold so right clicks are better distinguished from right drags especially on large screens * ignore mac files too * dont use less than 1 as a drag threshold Co-authored-by: Chris Fairclough --- .gitignore | 3 +++ Scripts/Editor/NodeEditorAction.cs | 8 ++++++-- Scripts/Editor/NodeEditorWindow.cs | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 64ab4c0..c75a01e 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ sysinfo.txt .git.meta .gitignore.meta .gitattributes.meta + +# OS X only: +.DS_Store \ No newline at end of file diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 1a02556..b112732 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 a751722..4f0a102 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -81,6 +81,8 @@ namespace XNodeEditor { graphEditor.OnWindowFocus(); if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); } + + dragThreshold = Math.Max(1f, Screen.width / 1000f); } void OnLostFocus() {