Add numeric input restriction

This commit is contained in:
Ishmaeel 2024-08-10 21:24:48 +10:00
parent df07a64661
commit 9285b9c5f4
3 changed files with 12 additions and 3 deletions

View file

@ -525,12 +525,15 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
}
}
public int MaxResultLowerLimit => 100;
public int MaxResultUpperLimit => 100000;
public int MaxResult
{
get => Settings.MaxResult;
set
{
Settings.MaxResult = Math.Clamp(value, 100, 10000);
Settings.MaxResult = Math.Clamp(value, MaxResultLowerLimit, MaxResultUpperLimit);
OnPropertyChanged();
}
}

View file

@ -363,6 +363,7 @@
Margin="0,9,0,6"
HorizontalAlignment="Left"
VerticalAlignment="Center"
PreviewTextInput="AllowOnlyNumericInput"
Text="{Binding MaxResult}"
ToolTip="{DynamicResource plugin_explorer_Maximum_Results_Tooltip}"/>
</Grid>

View file

@ -1,4 +1,4 @@
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.Explorer.ViewModels;
using System.Collections.Generic;
using System.ComponentModel;
@ -40,7 +40,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
}
private void AccessLinkDragDrop(string containerName, DragEventArgs e)
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
@ -94,5 +94,10 @@ namespace Flow.Launcher.Plugin.Explorer.Views
{
AccessLinkDragDrop("IndexSearchExcludedPath", e);
}
private void AllowOnlyNumericInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
{
e.Handled = e.Text.ToCharArray().Any(c => !char.IsDigit(c));
}
}
}