Skip to content

Commit

Permalink
Fixes #462
Browse files Browse the repository at this point in the history
  • Loading branch information
rds1983 committed Apr 23, 2024
1 parent ff51a94 commit e2acc5f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/Myra/Graphics2D/UI/Containers/SplitPane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ private void HandleOnPressedChanged(object sender, EventArgs args)
{
_handleDown = null;
_mouseCoord = null;

MyraEnvironment.SetMouseCursorFromWidget = true;
MyraEnvironment.MouseCursorType = MouseCursor ?? MyraEnvironment.DefaultMouseCursorType;
}
else if (Desktop != null)
{
Expand All @@ -140,6 +143,16 @@ private void HandleOnPressedChanged(object sender, EventArgs args)
_mouseCoord = Orientation == Orientation.Horizontal
? Desktop.TouchPosition.Value.X - handleGlobalPos.X
: Desktop.TouchPosition.Value.Y - handleGlobalPos.Y;

MyraEnvironment.SetMouseCursorFromWidget = false;
if (Orientation == Orientation.Horizontal)
{
MyraEnvironment.MouseCursorType = MouseCursorType.SizeWE;
}
else
{
MyraEnvironment.MouseCursorType = MouseCursorType.SizeNS;
}
}
}

Expand Down Expand Up @@ -218,10 +231,12 @@ public void Reset()

if (Orientation == Orientation.Horizontal)
{
handle.MouseCursor = MouseCursorType.SizeWE;
handle.VerticalAlignment = VerticalAlignment.Stretch;
}
else
{
handle.MouseCursor = MouseCursorType.SizeNS;
handle.HorizontalAlignment = HorizontalAlignment.Stretch;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Myra/Graphics2D/UI/Widget.Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ void IInputEventsProcessor.ProcessEvent(InputEventType eventType)
}

_lastMouseMovement = null;
if (MouseCursor != null)

if (MyraEnvironment.SetMouseCursorFromWidget && MouseCursor != null)
{
MyraEnvironment.MouseCursorType = MyraEnvironment.DefaultMouseCursorType;
}
Expand All @@ -297,7 +298,7 @@ void IInputEventsProcessor.ProcessEvent(InputEventType eventType)
break;
case InputEventType.MouseEntered:
_lastMouseMovement = DateTime.Now;
if (MouseCursor != null)
if (MyraEnvironment.SetMouseCursorFromWidget && MouseCursor != null)
{
MyraEnvironment.MouseCursorType = MouseCursor.Value;
}
Expand All @@ -307,7 +308,6 @@ void IInputEventsProcessor.ProcessEvent(InputEventType eventType)
break;
case InputEventType.MouseMoved:
_lastMouseMovement = DateTime.Now;

OnMouseMoved();
MouseMoved.Invoke(this);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/Myra/MyraEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ private static IntPtr GetSystemCursor(SDL_SystemCursor type)
private static MouseCursorType _mouseCursorType;
private static AssetManager _defaultAssetManager;

public static bool SetMouseCursorFromWidget { get; set; } = true;

public static MouseCursorType MouseCursorType
{
get => _mouseCursorType;
Expand Down

0 comments on commit e2acc5f

Please sign in to comment.