Skip to content

Commit b020143

Browse files
committed
Use debounce helper to keep tooltip from disappearing to quickly
1 parent 093c4f5 commit b020143

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector/RangeSelector.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using Microsoft.Toolkit.Uwp.UI.Extensions;
67
using Windows.Foundation;
78
using Windows.System;
89
using Windows.UI.Xaml;
@@ -35,6 +36,7 @@ public partial class RangeSelector : Control
3536
private const double DefaultMinimum = 0.0;
3637
private const double DefaultMaximum = 1.0;
3738
private const double DefaultStepFrequency = 1;
39+
private static readonly TimeSpan TimeToHideToolTipOnKeyUp = TimeSpan.FromSeconds(1);
3840

3941
/// <summary>
4042
/// Identifies the Minimum dependency property.
@@ -61,6 +63,8 @@ public partial class RangeSelector : Control
6163
/// </summary>
6264
public static readonly DependencyProperty StepFrequencyProperty = DependencyProperty.Register(nameof(StepFrequency), typeof(double), typeof(RangeSelector), new PropertyMetadata(DefaultStepFrequency));
6365

66+
private readonly DispatcherTimer dispatcherTimer = new DispatcherTimer();
67+
6468
private Border _outOfRangeContentContainer;
6569
private Rectangle _activeRectangle;
6670
private Thumb _minThumb;
@@ -247,7 +251,9 @@ private void Thumb_KeyUp(object sender, KeyRoutedEventArgs e)
247251
case VirtualKey.Right:
248252
if (_toolTip != null)
249253
{
250-
_toolTip.Visibility = Visibility.Collapsed;
254+
dispatcherTimer.Debounce(
255+
() => _toolTip.Visibility = Visibility.Collapsed,
256+
TimeToHideToolTipOnKeyUp);
251257
}
252258

253259
e.Handled = true;

0 commit comments

Comments
 (0)