From 6481897ffa43eaa6f6b6787c7c8bd91f7cd2ccbc Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 22 May 2024 07:52:25 -0500 Subject: [PATCH 1/2] Fix SliderControl not being unfocused on value change. --- Source/Editor/GUI/Input/SliderControl.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Editor/GUI/Input/SliderControl.cs b/Source/Editor/GUI/Input/SliderControl.cs index c0cec3f56..3b7c4daf7 100644 --- a/Source/Editor/GUI/Input/SliderControl.cs +++ b/Source/Editor/GUI/Input/SliderControl.cs @@ -132,6 +132,8 @@ namespace FlaxEditor.GUI.Input _isSliding = false; EndMouseCapture(); SlidingEnd?.Invoke(); + Defocus(); + Parent?.Focus(); } /// @@ -183,6 +185,8 @@ namespace FlaxEditor.GUI.Input { // Click change Value += (mousePosition < _thumbCenter ? -1 : 1) * 10; + Defocus(); + Parent?.Focus(); } } @@ -364,7 +368,7 @@ namespace FlaxEditor.GUI.Input }; _slider.ValueChanged += SliderOnValueChanged; _slider.SlidingStart += SlidingStart; - _slider.SlidingEnd += SlidingEnd; + _slider.SlidingEnd += SliderOnSliderEnd; _textBox = new TextBox(false, split, 0) { Text = _value.ToString(CultureInfo.InvariantCulture), @@ -375,6 +379,13 @@ namespace FlaxEditor.GUI.Input _textBox.EditEnd += OnTextBoxEditEnd; } + private void SliderOnSliderEnd() + { + SlidingEnd?.Invoke(); + Defocus(); + Parent?.Focus(); + } + private void SliderOnValueChanged() { if (_valueIsChanging) @@ -397,6 +408,8 @@ namespace FlaxEditor.GUI.Input { UpdateText(); } + Defocus(); + Parent?.Focus(); } /// From 79dbad6547317fc7ecbee9cdc6bedb198111b926 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 22 May 2024 15:56:39 -0500 Subject: [PATCH 2/2] Ensure slider max and min are snapped to if the value is close to them. --- Source/Editor/GUI/Input/SliderControl.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Editor/GUI/Input/SliderControl.cs b/Source/Editor/GUI/Input/SliderControl.cs index 3b7c4daf7..a80b5e230 100644 --- a/Source/Editor/GUI/Input/SliderControl.cs +++ b/Source/Editor/GUI/Input/SliderControl.cs @@ -201,6 +201,10 @@ namespace FlaxEditor.GUI.Input // Update sliding var slidePosition = location + Root.TrackingMouseOffset; Value = Mathf.Remap(slidePosition.X, 4, TrackSize - 4, Minimum, Maximum); + if (Mathf.NearEqual(Value, Maximum)) + Value = Maximum; + else if (Mathf.NearEqual(Value, Minimum)) + Value = Minimum; } else {