Skip to content

Commit 3b394c8

Browse files
authored
Fixes #3115. TextView should use Command.ShowContextMenu not Command.Accept (#3118)
* Command.Accept->Command.ShowContextMenu + Unit Test * fixed unit test
1 parent 0b7ca7b commit 3b394c8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Terminal.Gui/Views/TextView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ void SetInitialProperties ()
16661666
AddCommand (Command.Undo, () => { Undo (); return true; });
16671667
AddCommand (Command.Redo, () => { Redo (); return true; });
16681668
AddCommand (Command.DeleteAll, () => { DeleteAll (); return true; });
1669-
AddCommand (Command.Accept, () => {
1669+
AddCommand (Command.ShowContextMenu, () => {
16701670
ContextMenu!.Position = new Point (CursorPosition.X - _leftColumn + 2, CursorPosition.Y - _topRow + 2);
16711671
ShowContextMenu ();
16721672
return true;
@@ -1775,7 +1775,7 @@ void SetInitialProperties ()
17751775
ContextMenu = new ContextMenu () { MenuItems = BuildContextMenuBarItem () };
17761776
ContextMenu.KeyChanged += ContextMenu_KeyChanged!;
17771777

1778-
KeyBindings.Add ((KeyCode)ContextMenu.Key, KeyBindingScope.HotKey, Command.Accept);
1778+
KeyBindings.Add ((KeyCode)ContextMenu.Key, KeyBindingScope.HotKey, Command.ShowContextMenu);
17791779
}
17801780

17811781
private MenuBarItem BuildContextMenuBarItem ()

UnitTests/Views/TextViewTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,6 +3047,10 @@ public void KeyBindings_Command ()
30473047
Assert.False (tv.NewKeyDownEvent (Application.AlternateForwardKey));
30483048
Assert.False (tv.NewKeyDownEvent (new (KeyCode.Tab | KeyCode.CtrlMask | KeyCode.ShiftMask)));
30493049
Assert.False (tv.NewKeyDownEvent (Application.AlternateBackwardKey));
3050+
3051+
Assert.True (tv.NewKeyDownEvent (ContextMenu.DefaultKey));
3052+
Assert.True (tv.ContextMenu != null && tv.ContextMenu.MenuBar.Visible);
3053+
30503054
}
30513055

30523056
[Fact]

0 commit comments

Comments
 (0)