Fixes #2511. Cannot cycle selections in lists/tables when Numlock is pressed. (#2513)

* Fixes #2511. Cannot cycle selections in lists/tables when Numlock is pressed.

* The Capslock, Numlock and Scrolllock tests can be run once.

* Done requested changes.
This commit is contained in:
BDisp
2023-04-09 10:14:02 +01:00
committed by GitHub
parent 1d00efb3d3
commit 8ac9273493
2 changed files with 30 additions and 2 deletions

View File

@@ -212,14 +212,14 @@ namespace Terminal.Gui {
/// <summary>
/// Returns true if <paramref name="kb"/> is a searchable key
/// (e.g. letters, numbers etc) that is valid to pass to to this
/// (e.g. letters, numbers, etc) that are valid to pass to this
/// class for search filtering.
/// </summary>
/// <param name="kb"></param>
/// <returns></returns>
public static bool IsCompatibleKey (KeyEvent kb)
{
return !kb.IsAlt && !kb.IsCapslock && !kb.IsCtrl && !kb.IsScrolllock && !kb.IsNumlock;
return !kb.IsAlt && !kb.IsCtrl;
}
}
}

View File

@@ -376,5 +376,33 @@ namespace Terminal.Gui.TextTests {
Assert.Equal (-1, current = n.GetNextMatchingItem (current, "x", true));
}
[Fact]
public void IsCompatibleKey_Does_Not_Allow_Alt_And_Ctrl_Keys ()
{
// test all Keys
foreach (Key key in Enum.GetValues (typeof (Key))) {
var ke = new KeyEvent (key, new KeyModifiers () {
Alt = key == Key.AltMask,
Ctrl = key == Key.CtrlMask,
Shift = key == Key.ShiftMask
});
if (key == Key.AltMask || key == Key.CtrlMask) {
Assert.False (CollectionNavigator.IsCompatibleKey (ke));
} else {
Assert.True (CollectionNavigator.IsCompatibleKey (ke));
}
}
// test Capslock, Numlock and Scrolllock
Assert.True (CollectionNavigator.IsCompatibleKey (new KeyEvent (Key.Null, new KeyModifiers () {
Alt = false,
Ctrl = false,
Shift = false,
Capslock = true,
Numlock = true,
Scrolllock = true,
})));
}
}
}