mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
* 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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
})));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user