Changed how cursor is set back to default, so it doesnt keep setting itself

This commit is contained in:
Chandler Cox
2022-09-30 20:52:04 -05:00
parent e18002dd03
commit 3867cb5e97
2 changed files with 7 additions and 24 deletions

View File

@@ -56,6 +56,7 @@ namespace FlaxEditor.GUI.Input
private Float2 _startSlideLocation; private Float2 _startSlideLocation;
private double _clickStartTime = -1; private double _clickStartTime = -1;
private bool _cursorChanged;
/// <summary> /// <summary>
/// Occurs when value gets changed. /// Occurs when value gets changed.
@@ -263,8 +264,9 @@ namespace FlaxEditor.GUI.Input
if (CanUseSliding && SlideRect.Contains(location)) if (CanUseSliding && SlideRect.Contains(location))
{ {
Cursor = CursorType.SizeWE; Cursor = CursorType.SizeWE;
_cursorChanged = true;
} }
else if (!_isSliding) else if (_cursorChanged && !_isSliding)
{ {
Cursor = CursorType.Default; Cursor = CursorType.Default;
} }

View File

@@ -23,8 +23,7 @@ namespace FlaxEngine.GUI
private float _splitterValue; private float _splitterValue;
private Rectangle _splitterRect; private Rectangle _splitterRect;
private bool _splitterClicked, _mouseOverSplitter; private bool _splitterClicked, _mouseOverSplitter;
private bool _leftMouseButtonDown; private bool _cursorChanged;
private bool _rightMouseButtonDown;
/// <summary> /// <summary>
/// The first panel (left or upper based on Orientation). /// The first panel (left or upper based on Orientation).
@@ -168,10 +167,12 @@ namespace FlaxEngine.GUI
else if (_mouseOverSplitter) else if (_mouseOverSplitter)
{ {
Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS;
_cursorChanged = true;
} }
else if (!_leftMouseButtonDown && !_rightMouseButtonDown) else if (_cursorChanged)
{ {
Cursor = CursorType.Default; Cursor = CursorType.Default;
_cursorChanged = false;
} }
base.OnMouseMove(location); base.OnMouseMove(location);
@@ -180,16 +181,6 @@ namespace FlaxEngine.GUI
/// <inheritdoc /> /// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button) public override bool OnMouseDown(Float2 location, MouseButton button)
{ {
if (button == MouseButton.Left)
{
_leftMouseButtonDown = true;
}
if (button == MouseButton.Right)
{
_rightMouseButtonDown = true;
}
if (button == MouseButton.Left && _splitterRect.Contains(location)) if (button == MouseButton.Left && _splitterRect.Contains(location))
{ {
// Start moving splitter // Start moving splitter
@@ -204,16 +195,6 @@ namespace FlaxEngine.GUI
/// <inheritdoc /> /// <inheritdoc />
public override bool OnMouseUp(Float2 location, MouseButton button) public override bool OnMouseUp(Float2 location, MouseButton button)
{ {
if (button == MouseButton.Left)
{
_leftMouseButtonDown = false;
}
if (button == MouseButton.Right)
{
_rightMouseButtonDown = false;
}
if (_splitterClicked) if (_splitterClicked)
{ {
EndTracking(); EndTracking();