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:
parent
7ec429ba77
commit
ada6d85c51
@ -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)
|
||||
// {
|
||||
// }
|
||||
// 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();
|
||||
|
||||
@ -30,10 +30,15 @@ namespace XNodeEditor
|
||||
{
|
||||
Event e = Event.current;
|
||||
Matrix4x4 m = GUI.matrix;
|
||||
if (graph == null && !graphFindAttempted)
|
||||
if (graph == null)
|
||||
{
|
||||
if (!graphFindAttempted && !OnOpen(graphInstanceID, 0))
|
||||
{
|
||||
graphFindAttempted = true;
|
||||
if (!OnOpen(graphInstanceID, 0))
|
||||
return;
|
||||
}
|
||||
|
||||
if (graphFindAttempted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ namespace XNodeEditor
|
||||
}
|
||||
}
|
||||
|
||||
dragThreshold = Math.Max(1f, Screen.width / 1000f);
|
||||
// dragThreshold = Math.Max(1f, Screen.width / 1000f);
|
||||
}
|
||||
|
||||
private void OnLostFocus()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user