Skip to content

Commit

Permalink
Merge pull request #3344 from tkohlmeier/improve-package-list-keyboar…
Browse files Browse the repository at this point in the history
…d-search
  • Loading branch information
marticliment authored Feb 26, 2025
2 parents 2d3f19e + 1460f40 commit fecaf3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/SoftwarePages/AbstractPackagesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Name="ABSTRACT_PAGE"
NavigationCacheMode="Required"
xmlns:animations="using:CommunityToolkit.WinUI.Animations" xmlns:pkgClasses="using:UniGetUI.PackageEngine.PackageClasses"
KeyDown="{x:Bind PackageList_KeyDown}">
CharacterReceived="{x:Bind PackageList_CharacterReceived}">
<!-- PreviewKeyDown="{x:Bind PackageList_PreviewKeyDown}" -->

<animations:Implicit.ShowAnimations>
Expand Down
12 changes: 7 additions & 5 deletions src/UniGetUI/Pages/SoftwarePages/AbstractPackagesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,18 +490,20 @@ private void SelectAndScrollTo(int index)
));
}

public void PackageList_KeyDown(object sender, KeyRoutedEventArgs e)
public void PackageList_CharacterReceived(object sender, CharacterReceivedRoutedEventArgs e)
{
string key = ((char)e.Key).ToString().ToLower();
if ("abcdefghijklmnopqrsztuvwxyz1234567890".IndexOf(key) > -1)
char ch = Char.ToLower(e.Character);

if (('a' <= ch && ch <= 'z')
|| ('0' <= ch && ch <= '9'))
{
if (Environment.TickCount - LastKeyDown > QUERY_SEPARATION_TIME)
{
TypeQuery = key;
TypeQuery = ch.ToString();
}
else
{
TypeQuery += key;
TypeQuery += ch.ToString();
}

int IdQueryIndex = -1;
Expand Down

0 comments on commit fecaf3d

Please sign in to comment.