1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 01:06:01 +08:00

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 <chris@zulleon.com>
This commit is contained in:
chrisfairc 2020-05-27 07:20:20 +01:00 committed by GitHub
parent 8046e6e0bf
commit a8daac60b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

3
.gitignore vendored
View File

@ -25,3 +25,6 @@ sysinfo.txt
.git.meta
.gitignore.meta
.gitattributes.meta
# OS X only:
.DS_Store

View File

@ -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,9 +135,12 @@ namespace XNodeEditor {
Repaint();
}
} else if (e.button == 1 || e.button == 2) {
//check drag threshold for larger screens
if (e.delta.magnitude > dragThreshold) {
panOffset += e.delta * zoom;
isPanning = true;
}
}
break;
case EventType.MouseDown:
Repaint();

View File

@ -81,6 +81,8 @@ namespace XNodeEditor {
graphEditor.OnWindowFocus();
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
}
dragThreshold = Math.Max(1f, Screen.width / 1000f);
}
void OnLostFocus() {