diff --git a/Source/Editor/Gizmo/ViewportRubberBandSelector.cs b/Source/Editor/Gizmo/ViewportRubberBandSelector.cs
index 5ad861820..8b0fb1e97 100644
--- a/Source/Editor/Gizmo/ViewportRubberBandSelector.cs
+++ b/Source/Editor/Gizmo/ViewportRubberBandSelector.cs
@@ -34,12 +34,15 @@ public class ViewportRubberBandSelector
///
/// Triggers the start of a rubber band selection.
///
- public void TryStartingRubberBandSelection()
+ /// True if selection started, otherwise false.
+ public bool TryStartingRubberBandSelection()
{
if (!_isRubberBandSpanning && !_owner.Gizmos.Active.IsControllingMouse && !_owner.IsRightMouseButtonDown)
{
_tryStartRubberBand = true;
+ return true;
}
+ return false;
}
///
@@ -248,9 +251,12 @@ public class ViewportRubberBandSelector
///
/// Immediately stops the rubber band.
///
- public void StopRubberBand()
+ /// True if rubber band was active before stopping.
+ public bool StopRubberBand()
{
+ var result = _tryStartRubberBand;
_isRubberBandSpanning = false;
_tryStartRubberBand = false;
+ return result;
}
}
diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs
index da3cf5bf6..a1dc61b4a 100644
--- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs
+++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs
@@ -493,14 +493,18 @@ namespace FlaxEditor.Viewport
public override void OnLostFocus()
{
base.OnLostFocus();
- _rubberBandSelector.StopRubberBand();
+
+ if (_rubberBandSelector.StopRubberBand())
+ EndMouseCapture();
}
///
public override void OnMouseLeave()
{
base.OnMouseLeave();
- _rubberBandSelector.StopRubberBand();
+
+ if (_rubberBandSelector.StopRubberBand())
+ EndMouseCapture();
}
///
@@ -615,8 +619,11 @@ namespace FlaxEditor.Viewport
protected override void OnLeftMouseButtonDown()
{
base.OnLeftMouseButtonDown();
-
- _rubberBandSelector.TryStartingRubberBandSelection();
+
+ if (_rubberBandSelector.TryStartingRubberBandSelection())
+ {
+ StartMouseCapture();
+ }
}
///
@@ -629,6 +636,8 @@ namespace FlaxEditor.Viewport
// Select rubberbanded rect actor nodes or pick with gizmo
if (!_rubberBandSelector.ReleaseRubberBandSelection())
{
+ EndMouseCapture();
+
// Try to pick something with the current gizmo
Gizmos.Active?.Pick();
}