Skip to content

Commit

Permalink
Add a dragthreshold to better distunguish right clicks and right drags (
Browse files Browse the repository at this point in the history
#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 <[email protected]>
  • Loading branch information
chrisfairc and ChrisZul authored May 27, 2020
1 parent 8046e6e commit a8daac6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ sysinfo.txt
.git.meta
.gitignore.meta
.gitattributes.meta

# OS X only:
.DS_Store
8 changes: 6 additions & 2 deletions Scripts/Editor/NodeEditorAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public enum NodeActivity { Idle, HoldNode, DragNode, HoldGrid, DragGrid }
private Rect selectionBox;
private bool isDoubleClick = false;
private Vector2 lastMousePosition;
private float dragThreshold = 1f;

public void Controls() {
wantsMouseMove = true;
Expand Down Expand Up @@ -134,8 +135,11 @@ public void Controls() {
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:
Expand Down
2 changes: 2 additions & 0 deletions Scripts/Editor/NodeEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ void OnFocus() {
graphEditor.OnWindowFocus();
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
}

dragThreshold = Math.Max(1f, Screen.width / 1000f);
}

void OnLostFocus() {
Expand Down

0 comments on commit a8daac6

Please sign in to comment.