mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
This commit is contained in:
@@ -81,7 +81,7 @@ public class HotKeyTests
|
||||
[InlineData (KeyCode.ShiftMask | KeyCode.AltMask, true)]
|
||||
[InlineData (KeyCode.CtrlMask, false)]
|
||||
[InlineData (KeyCode.ShiftMask | KeyCode.CtrlMask, false)]
|
||||
public void KeyPress_Runs_Default_HotKey_Command (KeyCode mask, bool expected)
|
||||
public void NewKeyDownEvent_Runs_Default_HotKey_Command (KeyCode mask, bool expected)
|
||||
{
|
||||
var view = new View { HotKeySpecifier = (Rune)'^', Title = "^Test" };
|
||||
view.CanFocus = true;
|
||||
@@ -91,10 +91,10 @@ public class HotKeyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProcessKeyDown_Ignores_KeyBindings_Out_Of_Scope_SuperView ()
|
||||
public void NewKeyDownEvent_Ignores_Focus_KeyBindings_SuperView ()
|
||||
{
|
||||
var view = new View ();
|
||||
view.KeyBindings.Add (Key.A, Command.HotKey);
|
||||
view.KeyBindings.Add (Key.A, Command.HotKey); // implies KeyBindingScope.Focused - so this should not be invoked
|
||||
view.InvokingKeyBindings += (s, e) => { Assert.Fail (); };
|
||||
|
||||
var superView = new View ();
|
||||
@@ -105,7 +105,25 @@ public class HotKeyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProcessKeyDown_Invokes_HotKey_Command_With_SuperView ()
|
||||
public void NewKeyDownEvent_Honors_HotKey_KeyBindings_SuperView ()
|
||||
{
|
||||
var view = new View ();
|
||||
view.KeyBindings.Add (Key.A, KeyBindingScope.HotKey, Command.HotKey);
|
||||
bool invoked = false;
|
||||
view.InvokingKeyBindings += (s, e) => { invoked = true; };
|
||||
|
||||
var superView = new View ();
|
||||
superView.Add (view);
|
||||
|
||||
var ke = Key.A;
|
||||
superView.NewKeyDownEvent (ke);
|
||||
|
||||
Assert.True (invoked);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void NewKeyDownEvent_InNewKeyDownEventvokes_HotKey_Command_With_SuperView ()
|
||||
{
|
||||
var view = new View { HotKeySpecifier = (Rune)'^', Title = "^Test" };
|
||||
|
||||
|
||||
@@ -421,7 +421,7 @@ public class KeyboardEventTests (ITestOutputHelper output) : TestsAllViews
|
||||
var view = new KeyBindingsTestView ();
|
||||
view.CommandReturns = toReturn;
|
||||
|
||||
bool? result = view.OnInvokingKeyBindings (Key.A);
|
||||
bool? result = view.OnInvokingKeyBindings (Key.A, KeyBindingScope.HotKey | KeyBindingScope.Focused);
|
||||
Assert.Equal (expected, result);
|
||||
}
|
||||
|
||||
@@ -449,9 +449,9 @@ public class KeyboardEventTests (ITestOutputHelper output) : TestsAllViews
|
||||
public bool OnKeyUpContinued { get; set; }
|
||||
public override string Text { get; set; }
|
||||
|
||||
public override bool? OnInvokingKeyBindings (Key keyEvent)
|
||||
public override bool? OnInvokingKeyBindings (Key keyEvent, KeyBindingScope scope)
|
||||
{
|
||||
bool? handled = base.OnInvokingKeyBindings (keyEvent);
|
||||
bool? handled = base.OnInvokingKeyBindings (keyEvent, scope);
|
||||
|
||||
if (handled != null && (bool)handled)
|
||||
{
|
||||
|
||||
@@ -620,133 +620,133 @@ public class NavigationTests (ITestOutputHelper output)
|
||||
top1.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void HotKey_Will_Invoke_KeyPressed_Only_For_The_MostFocused_With_Top_KeyPress_Event ()
|
||||
{
|
||||
var sbQuiting = false;
|
||||
var tfQuiting = false;
|
||||
var topQuiting = false;
|
||||
// [Fact]
|
||||
// [AutoInitShutdown]
|
||||
// public void HotKey_Will_Invoke_KeyPressed_Only_For_The_MostFocused_With_Top_KeyPress_Event ()
|
||||
// {
|
||||
// var sbQuiting = false;
|
||||
// var tfQuiting = false;
|
||||
// var topQuiting = false;
|
||||
|
||||
var sb = new StatusBar (
|
||||
new StatusItem []
|
||||
{
|
||||
new (
|
||||
KeyCode.CtrlMask | KeyCode.Q,
|
||||
"~^Q~ Quit",
|
||||
() => sbQuiting = true
|
||||
)
|
||||
}
|
||||
);
|
||||
var tf = new TextField ();
|
||||
tf.KeyDown += Tf_KeyPressed;
|
||||
// var sb = new StatusBar (
|
||||
// new Shortcut []
|
||||
// {
|
||||
// new (
|
||||
// KeyCode.CtrlMask | KeyCode.Q,
|
||||
// "Quit",
|
||||
// () => sbQuiting = true
|
||||
// )
|
||||
// }
|
||||
// );
|
||||
// var tf = new TextField ();
|
||||
// tf.KeyDown += Tf_KeyPressed;
|
||||
|
||||
void Tf_KeyPressed (object sender, Key obj)
|
||||
{
|
||||
if (obj.KeyCode == (KeyCode.Q | KeyCode.CtrlMask))
|
||||
{
|
||||
obj.Handled = tfQuiting = true;
|
||||
}
|
||||
}
|
||||
// void Tf_KeyPressed (object sender, Key obj)
|
||||
// {
|
||||
// if (obj.KeyCode == (KeyCode.Q | KeyCode.CtrlMask))
|
||||
// {
|
||||
// obj.Handled = tfQuiting = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
var win = new Window ();
|
||||
win.Add (sb, tf);
|
||||
Toplevel top = new ();
|
||||
top.KeyDown += Top_KeyPress;
|
||||
// var win = new Window ();
|
||||
// win.Add (sb, tf);
|
||||
// Toplevel top = new ();
|
||||
// top.KeyDown += Top_KeyPress;
|
||||
|
||||
void Top_KeyPress (object sender, Key obj)
|
||||
{
|
||||
if (obj.KeyCode == (KeyCode.Q | KeyCode.CtrlMask))
|
||||
{
|
||||
obj.Handled = topQuiting = true;
|
||||
}
|
||||
}
|
||||
// void Top_KeyPress (object sender, Key obj)
|
||||
// {
|
||||
// if (obj.KeyCode == (KeyCode.Q | KeyCode.CtrlMask))
|
||||
// {
|
||||
// obj.Handled = topQuiting = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
top.Add (win);
|
||||
Application.Begin (top);
|
||||
// top.Add (win);
|
||||
// Application.Begin (top);
|
||||
|
||||
Assert.False (sbQuiting);
|
||||
Assert.False (tfQuiting);
|
||||
Assert.False (topQuiting);
|
||||
// Assert.False (sbQuiting);
|
||||
// Assert.False (tfQuiting);
|
||||
// Assert.False (topQuiting);
|
||||
|
||||
Application.Driver.SendKeys ('Q', ConsoleKey.Q, false, false, true);
|
||||
Assert.False (sbQuiting);
|
||||
Assert.True (tfQuiting);
|
||||
Assert.False (topQuiting);
|
||||
// Application.Driver.SendKeys ('Q', ConsoleKey.Q, false, false, true);
|
||||
// Assert.False (sbQuiting);
|
||||
// Assert.True (tfQuiting);
|
||||
// Assert.False (topQuiting);
|
||||
|
||||
#if BROKE_WITH_2927
|
||||
tf.KeyPressed -= Tf_KeyPress;
|
||||
tfQuiting = false;
|
||||
Application.Driver.SendKeys ('q', ConsoleKey.Q, false, false, true);
|
||||
Application.MainLoop.RunIteration ();
|
||||
Assert.True (sbQuiting);
|
||||
Assert.False (tfQuiting);
|
||||
Assert.False (topQuiting);
|
||||
//#if BROKE_WITH_2927
|
||||
// tf.KeyPressed -= Tf_KeyPress;
|
||||
// tfQuiting = false;
|
||||
// Application.Driver.SendKeys ('q', ConsoleKey.Q, false, false, true);
|
||||
// Application.MainLoop.RunIteration ();
|
||||
// Assert.True (sbQuiting);
|
||||
// Assert.False (tfQuiting);
|
||||
// Assert.False (topQuiting);
|
||||
|
||||
sb.RemoveItem (0);
|
||||
sbQuiting = false;
|
||||
Application.Driver.SendKeys ('q', ConsoleKey.Q, false, false, true);
|
||||
Application.MainLoop.RunIteration ();
|
||||
Assert.False (sbQuiting);
|
||||
Assert.False (tfQuiting);
|
||||
// sb.RemoveItem (0);
|
||||
// sbQuiting = false;
|
||||
// Application.Driver.SendKeys ('q', ConsoleKey.Q, false, false, true);
|
||||
// Application.MainLoop.RunIteration ();
|
||||
// Assert.False (sbQuiting);
|
||||
// Assert.False (tfQuiting);
|
||||
|
||||
// This test is now invalid because `win` is focused, so it will receive the keypress
|
||||
Assert.True (topQuiting);
|
||||
#endif
|
||||
top.Dispose ();
|
||||
}
|
||||
//// This test is now invalid because `win` is focused, so it will receive the keypress
|
||||
// Assert.True (topQuiting);
|
||||
//#endif
|
||||
// top.Dispose ();
|
||||
// }
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void HotKey_Will_Invoke_KeyPressed_Only_For_The_MostFocused_Without_Top_KeyPress_Event ()
|
||||
{
|
||||
var sbQuiting = false;
|
||||
var tfQuiting = false;
|
||||
// [Fact]
|
||||
// [AutoInitShutdown]
|
||||
// public void HotKey_Will_Invoke_KeyPressed_Only_For_The_MostFocused_Without_Top_KeyPress_Event ()
|
||||
// {
|
||||
// var sbQuiting = false;
|
||||
// var tfQuiting = false;
|
||||
|
||||
var sb = new StatusBar (
|
||||
new StatusItem []
|
||||
{
|
||||
new (
|
||||
KeyCode.CtrlMask | KeyCode.Q,
|
||||
"~^Q~ Quit",
|
||||
() => sbQuiting = true
|
||||
)
|
||||
}
|
||||
);
|
||||
var tf = new TextField ();
|
||||
tf.KeyDown += Tf_KeyPressed;
|
||||
// var sb = new StatusBar (
|
||||
// new Shortcut []
|
||||
// {
|
||||
// new (
|
||||
// KeyCode.CtrlMask | KeyCode.Q,
|
||||
// "~^Q~ Quit",
|
||||
// () => sbQuiting = true
|
||||
// )
|
||||
// }
|
||||
// );
|
||||
// var tf = new TextField ();
|
||||
// tf.KeyDown += Tf_KeyPressed;
|
||||
|
||||
void Tf_KeyPressed (object sender, Key obj)
|
||||
{
|
||||
if (obj.KeyCode == (KeyCode.Q | KeyCode.CtrlMask))
|
||||
{
|
||||
obj.Handled = tfQuiting = true;
|
||||
}
|
||||
}
|
||||
// void Tf_KeyPressed (object sender, Key obj)
|
||||
// {
|
||||
// if (obj.KeyCode == (KeyCode.Q | KeyCode.CtrlMask))
|
||||
// {
|
||||
// obj.Handled = tfQuiting = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
var win = new Window ();
|
||||
win.Add (sb, tf);
|
||||
Toplevel top = new ();
|
||||
top.Add (win);
|
||||
Application.Begin (top);
|
||||
// var win = new Window ();
|
||||
// win.Add (sb, tf);
|
||||
// Toplevel top = new ();
|
||||
// top.Add (win);
|
||||
// Application.Begin (top);
|
||||
|
||||
Assert.False (sbQuiting);
|
||||
Assert.False (tfQuiting);
|
||||
// Assert.False (sbQuiting);
|
||||
// Assert.False (tfQuiting);
|
||||
|
||||
Application.Driver.SendKeys ('Q', ConsoleKey.Q, false, false, true);
|
||||
Assert.False (sbQuiting);
|
||||
Assert.True (tfQuiting);
|
||||
// Application.Driver.SendKeys ('Q', ConsoleKey.Q, false, false, true);
|
||||
// Assert.False (sbQuiting);
|
||||
// Assert.True (tfQuiting);
|
||||
|
||||
tf.KeyDown -= Tf_KeyPressed;
|
||||
tfQuiting = false;
|
||||
Application.Driver.SendKeys ('Q', ConsoleKey.Q, false, false, true);
|
||||
Application.MainLoop.RunIteration ();
|
||||
#if BROKE_WITH_2927
|
||||
Assert.True (sbQuiting);
|
||||
Assert.False (tfQuiting);
|
||||
#endif
|
||||
top.Dispose ();
|
||||
}
|
||||
// tf.KeyDown -= Tf_KeyPressed;
|
||||
// tfQuiting = false;
|
||||
// Application.Driver.SendKeys ('Q', ConsoleKey.Q, false, false, true);
|
||||
// Application.MainLoop.RunIteration ();
|
||||
//#if BROKE_WITH_2927
|
||||
// Assert.True (sbQuiting);
|
||||
// Assert.False (tfQuiting);
|
||||
//#endif
|
||||
// top.Dispose ();
|
||||
// }
|
||||
|
||||
[Fact]
|
||||
[SetupFakeDriver]
|
||||
@@ -1535,7 +1535,6 @@ public class NavigationTests (ITestOutputHelper output)
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void WindowDispose_CanFocusProblem ()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in New Issue
Block a user