Fixed listView issue.

Added ability to mark/unmark all to ListView
This commit is contained in:
Tig
2024-10-14 17:30:30 -06:00
parent 89d8b74c3d
commit b766e4efdd
2 changed files with 61 additions and 12 deletions

View File

@@ -522,7 +522,7 @@ Item 6",
}
[Fact]
public void ListViewSelectThenDown ()
public void AllowsMarking_True_SpaceWithShift_SelectsThenDown ()
{
var lv = new ListView { Source = new ListWrapper<string> (["One", "Two", "Three"]) };
lv.AllowsMarking = true;
@@ -537,12 +537,8 @@ Item 6",
Assert.False (lv.Source.IsMarked (1));
Assert.False (lv.Source.IsMarked (2));
lv.KeyBindings.Add (Key.Space.WithShift, Command.Select, Command.Down);
Key key = Key.Space.WithShift;
// view should indicate that it has accepted and consumed the event
Assert.True (lv.NewKeyDownEvent (key));
Assert.True (lv.NewKeyDownEvent (Key.Space.WithShift));
// first item should now be selected
Assert.Equal (0, lv.SelectedItem);
@@ -553,7 +549,7 @@ Item 6",
Assert.False (lv.Source.IsMarked (2));
// Press key combo again
Assert.True (lv.NewKeyDownEvent (key));
Assert.True (lv.NewKeyDownEvent (Key.Space.WithShift));
// second item should now be selected
Assert.Equal (1, lv.SelectedItem);
@@ -564,21 +560,21 @@ Item 6",
Assert.False (lv.Source.IsMarked (2));
// Press key combo again
Assert.True (lv.NewKeyDownEvent (key));
Assert.True (lv.NewKeyDownEvent (Key.Space.WithShift));
Assert.Equal (2, lv.SelectedItem);
Assert.True (lv.Source.IsMarked (0));
Assert.True (lv.Source.IsMarked (1));
Assert.False (lv.Source.IsMarked (2));
// Press key combo again
Assert.True (lv.NewKeyDownEvent (key));
Assert.True (lv.NewKeyDownEvent (Key.Space.WithShift));
Assert.Equal (2, lv.SelectedItem); // cannot move down any further
Assert.True (lv.Source.IsMarked (0));
Assert.True (lv.Source.IsMarked (1));
Assert.True (lv.Source.IsMarked (2)); // but can toggle marked
// Press key combo again
Assert.True (lv.NewKeyDownEvent (key));
Assert.True (lv.NewKeyDownEvent (Key.Space.WithShift));
Assert.Equal (2, lv.SelectedItem); // cannot move down any further
Assert.True (lv.Source.IsMarked (0));
Assert.True (lv.Source.IsMarked (1));