mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Fixed flow of graphFindAttempted in NodeEditorGUI.cs.
Improved handling of drag threshold.
This commit is contained in:
parent
7ec429ba77
commit
ada6d85c51
@ -79,7 +79,8 @@ namespace XNodeEditor
|
|||||||
private Rect selectionBox;
|
private Rect selectionBox;
|
||||||
private bool isDoubleClick;
|
private bool isDoubleClick;
|
||||||
private Vector2 lastMousePosition;
|
private Vector2 lastMousePosition;
|
||||||
private float dragThreshold = 1f;
|
private Vector2 lastMouseDownPosition;
|
||||||
|
private readonly float dragThreshold = 5f;
|
||||||
|
|
||||||
public void Controls()
|
public void Controls()
|
||||||
{
|
{
|
||||||
@ -242,17 +243,19 @@ namespace XNodeEditor
|
|||||||
}
|
}
|
||||||
else if (e.button == 1 || e.button == 2)
|
else if (e.button == 1 || e.button == 2)
|
||||||
{
|
{
|
||||||
//check drag threshold for larger screens
|
// Check drag threshold for larger screens
|
||||||
// if (e.delta.magnitude > dragThreshold)
|
if (isPanning || (lastMouseDownPosition - e.mousePosition).sqrMagnitude >
|
||||||
// {
|
dragThreshold * dragThreshold)
|
||||||
// }
|
{
|
||||||
isPanning = true;
|
isPanning = true;
|
||||||
panOffset += e.delta * zoom;
|
panOffset += e.delta * zoom;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EventType.MouseDown:
|
case EventType.MouseDown:
|
||||||
Repaint();
|
Repaint();
|
||||||
|
lastMouseDownPosition = e.mousePosition;
|
||||||
if (e.button == 0)
|
if (e.button == 0)
|
||||||
{
|
{
|
||||||
draggedOutputReroutes.Clear();
|
draggedOutputReroutes.Clear();
|
||||||
|
|||||||
@ -30,10 +30,15 @@ namespace XNodeEditor
|
|||||||
{
|
{
|
||||||
Event e = Event.current;
|
Event e = Event.current;
|
||||||
Matrix4x4 m = GUI.matrix;
|
Matrix4x4 m = GUI.matrix;
|
||||||
if (graph == null && !graphFindAttempted)
|
if (graph == null)
|
||||||
|
{
|
||||||
|
if (!graphFindAttempted && !OnOpen(graphInstanceID, 0))
|
||||||
{
|
{
|
||||||
graphFindAttempted = true;
|
graphFindAttempted = true;
|
||||||
if (!OnOpen(graphInstanceID, 0))
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (graphFindAttempted)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -142,7 +142,7 @@ namespace XNodeEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dragThreshold = Math.Max(1f, Screen.width / 1000f);
|
// dragThreshold = Math.Max(1f, Screen.width / 1000f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLostFocus()
|
private void OnLostFocus()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user