Repeating a character in search will jump to next element starting with this character only at the beginning of the search

Means repeating a character in the middle of a search the character will be appended to the search string instead of jumping to next element (as this would prevent searching for any item which has same characters twice next to each other)

Fixes #30 https://github.com/Hofknecht/SystemTrayMenu/issues/30
This commit is contained in:
Peter Kirmeier 2019-07-19 18:58:16 +02:00
parent 04396f7134
commit 381dc3c8a0

View file

@ -780,14 +780,13 @@ namespace SystemTrayMenu
if (string.IsNullOrEmpty(KeySearchString))
{
// no search string set, start new search
// no search string set, start new search with initial letter
KeySearchString += letter;
SelectByKey(Keys.None, KeySearchString);
}
else if (KeySearchString.LastOrDefault().ToString() == letter)
else if (KeySearchString.Length == 1 && KeySearchString.LastOrDefault().ToString() == letter)
{
// previous letter pressed again, jump to next element
KeySearchString += letter;
// initial letter pressed again, jump to next element
SelectByKey(Keys.None, letter);
}
else