value boxes now hide your slide and return your mouse to the original position.

This commit is contained in:
Chandler Cox
2022-10-19 21:41:58 -05:00
parent f6857f66ba
commit 78bd7713a9

View File

@@ -57,6 +57,7 @@ namespace FlaxEditor.GUI.Input
private Float2 _startSlideLocation;
private double _clickStartTime = -1;
private bool _cursorChanged;
private Float2 _mouseClickedPosition;
/// <summary>
/// Occurs when value gets changed.
@@ -244,8 +245,12 @@ namespace FlaxEditor.GUI.Input
_startSlideLocation = location;
_startSlideValue = _value;
StartMouseCapture(true);
Cursor = CursorType.SizeWE;
// Hide cursor and cache location
Cursor = CursorType.Hidden;
_mouseClickedPosition = location;
_cursorChanged = true;
SlidingStart?.Invoke();
return true;
}
@@ -268,7 +273,7 @@ namespace FlaxEditor.GUI.Input
}
// Update cursor type so user knows they can slide value
if (CanUseSliding && SlideRect.Contains(location))
if (CanUseSliding && SlideRect.Contains(location) && !_isSliding)
{
Cursor = CursorType.SizeWE;
_cursorChanged = true;
@@ -287,7 +292,8 @@ namespace FlaxEditor.GUI.Input
{
if (button == MouseButton.Left && _isSliding)
{
// End sliding
// End sliding and return mouse to original location
Root.MousePosition = ScreenPos + _mouseClickedPosition;
EndSliding();
return true;
}