diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs
index d28d04e1e..b050d5ae2 100644
--- a/Source/Editor/Surface/SurfaceNode.cs
+++ b/Source/Editor/Surface/SurfaceNode.cs
@@ -76,6 +76,11 @@ namespace FlaxEditor.Surface
/// The footer rectangle (local space).
///
protected Rectangle _footerRect;
+
+ ///
+ /// The last mouse down position.
+ ///
+ protected Float2 _mouseDownMousePosition;
///
/// The node archetype.
@@ -163,8 +168,6 @@ namespace FlaxEditor.Surface
///
protected virtual Color ArchetypeColor => GroupArchetype.Color;
- private Float2 mouseDownMousePosition;
-
///
/// Calculates the size of the node including header, footer, and margins.
///
@@ -1166,10 +1169,9 @@ namespace FlaxEditor.Surface
if (base.OnMouseDown(location, button))
return true;
+ _mouseDownMousePosition = location;
if (button == MouseButton.Left && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
return true;
- if (button == MouseButton.Right)
- mouseDownMousePosition = Input.Mouse.Position;
return false;
}
@@ -1180,18 +1182,22 @@ namespace FlaxEditor.Surface
if (base.OnMouseUp(location, button))
return true;
- // Close/ delete
- bool canDelete = !Surface.IsConnecting && !Surface.WasSelecting && !Surface.WasMovingSelection;
- if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
+ if (button == MouseButton.Left)
{
- Surface.Delete(this);
- return true;
+ // Close/delete
+ bool canDelete = !Surface.IsConnecting && !Surface.WasSelecting && !Surface.WasMovingSelection;
+ if (canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 &&
+ _closeButtonRect.Contains(ref location) && _closeButtonRect.Contains(ref _mouseDownMousePosition))
+ {
+ Surface.Delete(this);
+ return true;
+ }
}
// Secondary Context Menu
if (button == MouseButton.Right)
{
- float distance = Float2.Distance(mouseDownMousePosition, Input.Mouse.Position);
+ float distance = Float2.Distance(_mouseDownMousePosition, location);
if (distance > 2.5f)
return true;
diff --git a/Source/Editor/Surface/VisjectSurface.Connecting.cs b/Source/Editor/Surface/VisjectSurface.Connecting.cs
index 22616f6ad..621f6105f 100644
--- a/Source/Editor/Surface/VisjectSurface.Connecting.cs
+++ b/Source/Editor/Surface/VisjectSurface.Connecting.cs
@@ -287,6 +287,7 @@ namespace FlaxEditor.Surface
// Reset instigator list
_connectionInstigators.Clear();
+ EndMouseCapture();
}
}
}