Nuked OnInvokingKeyBindings from RadioGroup

This commit is contained in:
Tig
2024-06-09 14:51:19 -06:00
parent 891eb29660
commit b4eccad1e2
3 changed files with 283 additions and 257 deletions

View File

@@ -14,12 +14,12 @@ public class RadioGroupTests (ITestOutputHelper output)
Assert.Equal (Rectangle.Empty, rg.Frame);
Assert.Equal (0, rg.SelectedItem);
rg = new() { RadioLabels = new [] { "Test" } };
rg = new () { RadioLabels = new [] { "Test" } };
Assert.True (rg.CanFocus);
Assert.Single (rg.RadioLabels);
Assert.Equal (0, rg.SelectedItem);
rg = new()
rg = new ()
{
X = 1,
Y = 2,
@@ -32,7 +32,7 @@ public class RadioGroupTests (ITestOutputHelper output)
Assert.Equal (new (1, 2, 20, 5), rg.Frame);
Assert.Equal (0, rg.SelectedItem);
rg = new() { X = 1, Y = 2, RadioLabels = new [] { "Test" } };
rg = new () { X = 1, Y = 2, RadioLabels = new [] { "Test" } };
var view = new View { Width = 30, Height = 40 };
view.Add (rg);
@@ -130,6 +130,51 @@ public class RadioGroupTests (ITestOutputHelper output)
Assert.Equal (1, rg.SelectedItem);
}
[Fact]
public void HotKey_For_View_SetsFocus ()
{
var superView = new View
{
CanFocus = true
};
superView.Add (new View { CanFocus = true });
var group = new RadioGroup
{
Title = "Radio_Group",
RadioLabels = new [] { "_Left", "_Right", "Cen_tered", "_Justified" }
};
superView.Add (group);
Assert.False (group.HasFocus);
Assert.Equal (0, group.SelectedItem);
group.NewKeyDownEvent (Key.G.WithAlt);
Assert.Equal (0, group.SelectedItem);
Assert.True (group.HasFocus);
}
[Fact]
public void HotKey_For_Item_SetsFocus ()
{
var superView = new View
{
CanFocus = true
};
superView.Add (new View { CanFocus = true });
var group = new RadioGroup { RadioLabels = new [] { "_Left", "_Right", "Cen_tered", "_Justified" } };
superView.Add (group);
Assert.False (group.HasFocus);
Assert.Equal (0, group.SelectedItem);
group.NewKeyDownEvent (Key.R);
Assert.Equal (1, group.SelectedItem);
Assert.True (group.HasFocus);
}
[Fact]
public void HotKey_Command_Does_Not_Accept ()
{
@@ -184,12 +229,8 @@ public class RadioGroupTests (ITestOutputHelper output)
var expected = @$"
┌────────────────────────────┐
│{
CM.Glyphs.Selected
} Test │
│{
CM.Glyphs.UnSelected
} New Test 你 │
│{CM.Glyphs.Selected} Test │
│{CM.Glyphs.UnSelected} New Test 你 │
│ │
└────────────────────────────┘
";
@@ -209,11 +250,7 @@ public class RadioGroupTests (ITestOutputHelper output)
expected = @$"
┌────────────────────────────┐
│{
CM.Glyphs.Selected
} Test {
CM.Glyphs.UnSelected
} New Test 你 │
│{CM.Glyphs.Selected} Test {CM.Glyphs.UnSelected} New Test 你 │
│ │
│ │
└────────────────────────────┘
@@ -234,11 +271,7 @@ public class RadioGroupTests (ITestOutputHelper output)
expected = @$"
┌────────────────────────────┐
│{
CM.Glyphs.Selected
} Test {
CM.Glyphs.UnSelected
} New Test 你 │
│{CM.Glyphs.Selected} Test {CM.Glyphs.UnSelected} New Test 你 │
│ │
│ │
└────────────────────────────┘