mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
* Add collection search matcher * Fix naming * fix naming * Move FileDialogCollectionNavigator to its own file (no longer private class) Add class diagram for collectionNavigation * Add ICollectionNavigator interface * Move to separate file IListCollectionNavigator * Update class diagram * update class diagram * Add tests for overriding ICollectionNavigatorMatcher * xmldoc and nullability warning fixes * Code Cleanup * Make requested changes to naming and terminology * Move to seperate namespace * Update class diagram and change TreeView to reference the interface not concrete class * Switch to implicit new * highlight that this class also works with tree view * Apply tig patch to ensure keybindings get priority over navigator See: https://github.com/gui-cs/Terminal.Gui/issues/4027#issuecomment-2810020893 * Apply 'keybinding has priority' fix to TreeView too * Apply 'keybindngs priority over navigation' fix to TableView * Remove entire branch for selectively returning false now that it is default when there is a keybinding collision * Make classes internal and remove 'custom' navigator that was configured in UICatlaogToplevel * Change logging in collection navigator from Trace to Debug * Switch to NewKeyDownEvent and directly setting HasFocus * Remove application top dependency * Remove references to application * Remove Application * Move new tests to parallel --------- Co-authored-by: Tig <tig@users.noreply.github.com>
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Terminal.Gui.ViewsTests;
|
|
|
|
[TestSubject (typeof (TableView))]
|
|
public class TableViewTests
|
|
{
|
|
[Fact]
|
|
public void TableView_CollectionNavigatorMatcher_KeybindingsOverrideNavigator ()
|
|
{
|
|
var dt = new DataTable ();
|
|
dt.Columns.Add ("blah");
|
|
|
|
dt.Rows.Add ("apricot");
|
|
dt.Rows.Add ("arm");
|
|
dt.Rows.Add ("bat");
|
|
dt.Rows.Add ("batman");
|
|
dt.Rows.Add ("bates hotel");
|
|
dt.Rows.Add ("candle");
|
|
|
|
var tableView = new TableView ();
|
|
tableView.Table = new DataTableSource (dt);
|
|
tableView.HasFocus = true;
|
|
tableView.KeyBindings.Add (Key.B, Command.Down);
|
|
|
|
Assert.Equal (0, tableView.SelectedRow);
|
|
|
|
// Keys should be consumed to move down the navigation i.e. to apricot
|
|
Assert.True (tableView.NewKeyDownEvent (Key.B));
|
|
Assert.Equal (1, tableView.SelectedRow);
|
|
|
|
Assert.True (tableView.NewKeyDownEvent (Key.B));
|
|
Assert.Equal (2, tableView.SelectedRow);
|
|
|
|
// There is no keybinding for Key.C so it hits collection navigator i.e. we jump to candle
|
|
Assert.True (tableView.NewKeyDownEvent (Key.C));
|
|
Assert.Equal (5, tableView.SelectedRow);
|
|
}
|
|
}
|