Skip to content

Commit 9285b9c

Browse files
committed
Add numeric input restriction
1 parent df07a64 commit 9285b9c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,15 @@ public string ExcludedFileTypes
525525
}
526526
}
527527

528+
public int MaxResultLowerLimit => 100;
529+
public int MaxResultUpperLimit => 100000;
530+
528531
public int MaxResult
529532
{
530533
get => Settings.MaxResult;
531534
set
532535
{
533-
Settings.MaxResult = Math.Clamp(value, 100, 10000);
536+
Settings.MaxResult = Math.Clamp(value, MaxResultLowerLimit, MaxResultUpperLimit);
534537
OnPropertyChanged();
535538
}
536539
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
Margin="0,9,0,6"
364364
HorizontalAlignment="Left"
365365
VerticalAlignment="Center"
366+
PreviewTextInput="AllowOnlyNumericInput"
366367
Text="{Binding MaxResult}"
367368
ToolTip="{DynamicResource plugin_explorer_Maximum_Results_Tooltip}"/>
368369
</Grid>

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
1+
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
22
using Flow.Launcher.Plugin.Explorer.ViewModels;
33
using System.Collections.Generic;
44
using System.ComponentModel;
@@ -40,7 +40,7 @@ public ExplorerSettings(SettingsViewModel viewModel)
4040
}
4141

4242

43-
43+
4444
private void AccessLinkDragDrop(string containerName, DragEventArgs e)
4545
{
4646
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
@@ -94,5 +94,10 @@ private void LbxExcludedPaths_OnDrop(object sender, DragEventArgs e)
9494
{
9595
AccessLinkDragDrop("IndexSearchExcludedPath", e);
9696
}
97+
98+
private void AllowOnlyNumericInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
99+
{
100+
e.Handled = e.Text.ToCharArray().Any(c => !char.IsDigit(c));
101+
}
97102
}
98103
}

0 commit comments

Comments
 (0)