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

Fixed flow of graphFindAttempted in NodeEditorGUI.cs.

Improved handling of drag threshold.
This commit is contained in:
Emre Dogan 2023-10-08 16:00:53 +01:00
parent 7ec429ba77
commit ada6d85c51
3 changed files with 19 additions and 11 deletions

View File

@ -79,7 +79,8 @@ namespace XNodeEditor
private Rect selectionBox;
private bool isDoubleClick;
private Vector2 lastMousePosition;
private float dragThreshold = 1f;
private Vector2 lastMouseDownPosition;
private readonly float dragThreshold = 5f;
public void Controls()
{
@ -242,17 +243,19 @@ namespace XNodeEditor
}
else if (e.button == 1 || e.button == 2)
{
//check drag threshold for larger screens
// if (e.delta.magnitude > dragThreshold)
// {
// }
isPanning = true;
panOffset += e.delta * zoom;
// Check drag threshold for larger screens
if (isPanning || (lastMouseDownPosition - e.mousePosition).sqrMagnitude >
dragThreshold * dragThreshold)
{
isPanning = true;
panOffset += e.delta * zoom;
}
}
break;
case EventType.MouseDown:
Repaint();
lastMouseDownPosition = e.mousePosition;
if (e.button == 0)
{
draggedOutputReroutes.Clear();

View File

@ -30,10 +30,15 @@ namespace XNodeEditor
{
Event e = Event.current;
Matrix4x4 m = GUI.matrix;
if (graph == null && !graphFindAttempted)
if (graph == null)
{
graphFindAttempted = true;
if (!OnOpen(graphInstanceID, 0))
if (!graphFindAttempted && !OnOpen(graphInstanceID, 0))
{
graphFindAttempted = true;
return;
}
if (graphFindAttempted)
{
return;
}

View File

@ -142,7 +142,7 @@ namespace XNodeEditor
}
}
dragThreshold = Math.Max(1f, Screen.width / 1000f);
// dragThreshold = Math.Max(1f, Screen.width / 1000f);
}
private void OnLostFocus()