diff --git a/Source/Engine/UI/GUI/Common/Slider.cs b/Source/Engine/UI/GUI/Common/Slider.cs
index 8c7b022fe..83a5c38e1 100644
--- a/Source/Engine/UI/GUI/Common/Slider.cs
+++ b/Source/Engine/UI/GUI/Common/Slider.cs
@@ -1,6 +1,7 @@
// Copyright (c) Wojciech Figat. All rights reserved.
using System;
+using System.Collections.Generic;
namespace FlaxEngine.GUI;
@@ -408,6 +409,38 @@ public class Slider : ContainerControl
base.OnLostFocus();
}
+ ///
+ public override Control OnNavigate(NavDirection direction, Float2 location, Control caller, List visited)
+ {
+ bool _isHorizontal = Direction is SliderDirection.HorizontalRight or SliderDirection.HorizontalLeft;
+
+ float _keyOrGamepadPosition = _isHorizontal ? location.X : location.Y;
+
+ if (_thumbRect.Contains(ref location))
+ {
+ _isSliding = true;
+ SlidingStart?.Invoke();
+ return this;
+ }
+
+ var SliderPosition = (Direction == SliderDirection.HorizontalRight || Direction == SliderDirection.VerticalDown) ? _keyOrGamepadPosition : - _keyOrGamepadPosition;
+ Value += (SliderPosition < _thumbCenter ? -1 : 1) * 10;
+
+ return base.OnNavigate(direction, location, caller, visited);
+ }
+
+ ///
+ public override bool OnKeyDown(KeyboardKeys key)
+ {
+ if (key == KeyboardKeys.Escape)
+ {
+ Defocus();
+ return true;
+ }
+
+ return base.OnKeyDown(key);
+ }
+
///
public override bool OnMouseDown(Float2 location, MouseButton button)
{
@@ -443,6 +476,21 @@ public class Slider : ContainerControl
return base.OnMouseDown(location, button);
}
+ ///
+ public override bool OnTouchDown(Float2 location, int pointerId)
+ {
+ if (base.OnTouchDown(location, pointerId))
+ return true;
+
+ if (!new Rectangle(Float2.Zero, Size).Contains(ref location))
+ {
+ Defocus();
+ return true;
+ }
+
+ return false;
+ }
+
///
public override void OnMouseMove(Float2 location)
{
@@ -474,6 +522,18 @@ public class Slider : ContainerControl
}
}
+ ///
+ public override void OnKeyUp(KeyboardKeys key)
+ {
+ if (key == KeyboardKeys.Escape && _isSliding)
+ {
+ EndSliding();
+ return;
+ }
+
+ base.OnKeyUp(key);
+ }
+
///
public override bool OnMouseUp(Float2 location, MouseButton button)
{
@@ -486,6 +546,18 @@ public class Slider : ContainerControl
return base.OnMouseUp(location, button);
}
+ ///
+ public override bool OnTouchUp(Float2 location, int pointerId)
+ {
+ if (base.OnTouchUp(location, pointerId) && _isSliding)
+ {
+ EndSliding();
+ return true;
+ }
+
+ return false;
+ }
+
///
public override void OnEndMouseCapture()
{