diff --git a/Terminal.Gui/View/View.Keyboard.cs b/Terminal.Gui/View/View.Keyboard.cs
index 37f2cf2c0..317079358 100644
--- a/Terminal.Gui/View/View.Keyboard.cs
+++ b/Terminal.Gui/View/View.Keyboard.cs
@@ -268,63 +268,84 @@ public partial class View // Keyboard APIs
return false;
}
- // By default the KeyBindingScope is View
-
+ // If there's a Focused subview, give it a chance (this recurses down the hierarchy)
if (Focused?.NewKeyDownEvent (key) == true)
{
return true;
}
+ // Before (fire the cancellable event)
if (RaiseKeyDown (key) || key.Handled)
{
return true;
}
// During (this is what can be cancelled)
- InvokingKeyBindings?.Invoke (this, key);
- if (key.Handled)
+ if (RaiseInvokingKeyBindings (key) || key.Handled)
{
return true;
}
- // TODO: NewKeyDownEvent returns bool. It should be bool? so state of InvokeCommand can be reflected up stack
-
- bool? handled = OnInvokingKeyBindings (key, KeyBindingScope.HotKey | KeyBindingScope.Focused);
-
- if (handled is { } && (bool)handled)
- {
- return true;
- }
-
- // TODO: The below is not right. OnXXX handlers are supposed to fire the events.
- // TODO: But I've moved it outside of the v-function to test something.
- // After (fire the cancellable event)
- // fire event
- ProcessKeyDown?.Invoke (this, key);
-
- if (!key.Handled && OnProcessKeyDown (key))
+ if (RaiseProcessKeyDown(key) || key.Handled)
{
return true;
}
return key.Handled;
- }
- private bool RaiseKeyDown (Key key)
- {
- // Before (fire the cancellable event)
- if (OnKeyDown (key) || key.Handled)
+ bool RaiseKeyDown (Key key)
{
- return true;
+ // Before (fire the cancellable event)
+ if (OnKeyDown (key) || key.Handled)
+ {
+ return true;
+ }
+
+ // fire event
+ KeyDown?.Invoke (this, key);
+
+ return key.Handled;
}
- // fire event
- KeyDown?.Invoke (this, key);
+ bool RaiseInvokingKeyBindings (Key key)
+ {
+ // BUGBUG: The proper pattern is for the v-method (OnInvokingKeyBindings) to be called first, then the event
+ InvokingKeyBindings?.Invoke (this, key);
- return key.Handled;
+ if (key.Handled)
+ {
+ return true;
+ }
+
+ // TODO: NewKeyDownEvent returns bool. It should be bool? so state of InvokeCommand can be reflected up stack
+
+ bool? handled = OnInvokingKeyBindings (key, KeyBindingScope.HotKey | KeyBindingScope.Focused);
+
+ if (handled is { } && (bool)handled)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ bool RaiseProcessKeyDown (Key key)
+ {
+ // BUGBUG: The proper pattern is for the v-method (OnProcessKeyDown) to be called first, then the event
+ ProcessKeyDown?.Invoke (this, key);
+
+ if (!key.Handled && OnProcessKeyDown (key))
+ {
+ return true;
+ }
+
+ return false;
+ }
}
+
+
///
/// Low-level API called when the user presses a key, allowing a view to pre-process the key down event. This is
/// called from before .
@@ -341,7 +362,7 @@ public partial class View // Keyboard APIs
///
/// Fires the event.
///
- public virtual bool OnKeyDown (Key keyEvent)
+ protected virtual bool OnKeyDown (Key keyEvent)
{
return false;
}
@@ -384,9 +405,8 @@ public partial class View // Keyboard APIs
/// KeyUp events.
///
///
- public virtual bool OnProcessKeyDown (Key keyEvent)
+ protected virtual bool OnProcessKeyDown (Key keyEvent)
{
- //ProcessKeyDown?.Invoke (this, keyEvent);
return keyEvent.Handled;
}
@@ -446,20 +466,20 @@ public partial class View // Keyboard APIs
}
return false;
- }
- private bool RaiseKeyUp (Key key)
- {
- // Before (fire the cancellable event)
- if (OnKeyUp (key) || key.Handled)
+ bool RaiseKeyUp (Key key)
{
- return true;
+ // Before (fire the cancellable event)
+ if (OnKeyUp (key) || key.Handled)
+ {
+ return true;
+ }
+
+ // fire event
+ KeyUp?.Invoke (this, key);
+
+ return key.Handled;
}
-
- // fire event
- KeyUp?.Invoke (this, key);
-
- return key.Handled;
}
diff --git a/Terminal.Gui/Views/DateField.cs b/Terminal.Gui/Views/DateField.cs
index 2e07f0afa..43060c0a5 100644
--- a/Terminal.Gui/Views/DateField.cs
+++ b/Terminal.Gui/Views/DateField.cs
@@ -131,7 +131,7 @@ public class DateField : TextField
public virtual void OnDateChanged (DateTimeEventArgs args) { DateChanged?.Invoke (this, args); }
///
- public override bool OnProcessKeyDown (Key a)
+ protected override bool OnProcessKeyDown (Key a)
{
// Ignore non-numeric characters.
if (a >= Key.D0 && a <= Key.D9)
diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs
index d0022fea0..78ed5b584 100644
--- a/Terminal.Gui/Views/FileDialog.cs
+++ b/Terminal.Gui/Views/FileDialog.cs
@@ -233,7 +233,7 @@ public class FileDialog : Dialog
_tbPath.TextChanged += (s, e) => PathChanged ();
_tableView.CellActivated += CellActivate;
- _tableView.KeyUp += (s, k) => k.Handled = TableView_KeyUp (k);
+ _tableView.KeyDown += (s, k) => k.Handled = TableView_KeyUp (k);
_tableView.SelectedCellChanged += TableView_SelectedCellChanged;
_tableView.KeyBindings.ReplaceCommands (Key.Home, Command.Start);
diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs
index 16a363755..8f7e3c1a0 100644
--- a/Terminal.Gui/Views/HexView.cs
+++ b/Terminal.Gui/Views/HexView.cs
@@ -452,7 +452,7 @@ public class HexView : View, IDesignable
public virtual void OnPositionChanged () { PositionChanged?.Invoke (this, new HexViewEventArgs (Position, CursorPosition, BytesPerLine)); }
///
- public override bool OnProcessKeyDown (Key keyEvent)
+ protected override bool OnProcessKeyDown (Key keyEvent)
{
if (!AllowEdits)
{
diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs
index fddd0482f..f7e65f843 100644
--- a/Terminal.Gui/Views/ListView.cs
+++ b/Terminal.Gui/Views/ListView.cs
@@ -803,7 +803,7 @@ public class ListView : View, IDesignable
}
///
- public override bool OnKeyDown (Key a)
+ protected override bool OnKeyDown (Key a)
{
// Enable user to find & select an item by typing text
if (CollectionNavigatorBase.IsCompatibleKey (a) && (!AllowsMarking && a == Key.Space))
diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs
index 576973ed6..6a2c6ffbe 100644
--- a/Terminal.Gui/Views/ScrollView.cs
+++ b/Terminal.Gui/Views/ScrollView.cs
@@ -388,7 +388,7 @@ public class ScrollView : View
}
///
- public override bool OnKeyDown (Key a)
+ protected override bool OnKeyDown (Key a)
{
if (base.OnKeyDown (a))
{
diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs
index 8e90bd42d..5da0b11e3 100644
--- a/Terminal.Gui/Views/TableView/TableView.cs
+++ b/Terminal.Gui/Views/TableView/TableView.cs
@@ -988,7 +988,7 @@ public class TableView : View
}
///
- public override bool OnKeyDown (Key key)
+ protected override bool OnKeyDown (Key key)
{
if (TableIsNullOrInvisible ())
{
diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs
index c9d681867..984f151f4 100644
--- a/Terminal.Gui/Views/TextField.cs
+++ b/Terminal.Gui/Views/TextField.cs
@@ -1055,7 +1055,7 @@ public class TextField : View
///
///
///
- public override bool OnProcessKeyDown (Key a)
+ protected override bool OnProcessKeyDown (Key a)
{
// Remember the cursor position because the new calculated cursor position is needed
// to be set BEFORE the TextChanged event is triggered.
diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs
index a6c740d1b..579b22f56 100644
--- a/Terminal.Gui/Views/TextValidateField.cs
+++ b/Terminal.Gui/Views/TextValidateField.cs
@@ -597,7 +597,7 @@ namespace Terminal.Gui
}
///
- public override bool OnProcessKeyDown (Key a)
+ protected override bool OnProcessKeyDown (Key a)
{
if (_provider is null)
{
diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs
index a539aadf3..f5436ea96 100644
--- a/Terminal.Gui/Views/TextView.cs
+++ b/Terminal.Gui/Views/TextView.cs
@@ -3703,7 +3703,7 @@ public class TextView : View
}
///
- public override bool OnProcessKeyDown (Key a)
+ protected override bool OnProcessKeyDown (Key a)
{
if (!CanFocus)
{
diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs
index b6e57dd90..4adbb5b1b 100644
--- a/Terminal.Gui/Views/TileView.cs
+++ b/Terminal.Gui/Views/TileView.cs
@@ -286,7 +286,7 @@ public class TileView : View
//// BUGBUG: Why is this not handled by a key binding???
///
- public override bool OnProcessKeyDown (Key keyEvent)
+ protected override bool OnProcessKeyDown (Key keyEvent)
{
var focusMoved = false;
diff --git a/Terminal.Gui/Views/TimeField.cs b/Terminal.Gui/Views/TimeField.cs
index b198d66a0..305a3ce59 100644
--- a/Terminal.Gui/Views/TimeField.cs
+++ b/Terminal.Gui/Views/TimeField.cs
@@ -177,7 +177,7 @@ public class TimeField : TextField
}
///
- public override bool OnProcessKeyDown (Key a)
+ protected override bool OnProcessKeyDown (Key a)
{
// Ignore non-numeric characters.
if (a.KeyCode is >= (KeyCode)(int)KeyCode.D0 and <= (KeyCode)(int)KeyCode.D9)
diff --git a/Terminal.Gui/Views/TreeView/TreeView.cs b/Terminal.Gui/Views/TreeView/TreeView.cs
index 1450a57ba..59fe8e04f 100644
--- a/Terminal.Gui/Views/TreeView/TreeView.cs
+++ b/Terminal.Gui/Views/TreeView/TreeView.cs
@@ -1182,7 +1182,7 @@ public class TreeView : View, ITreeView where T : class
}
///
- public override bool OnKeyDown (Key keyEvent)
+ protected override bool OnKeyDown (Key keyEvent)
{
if (!Enabled)
{
diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs
index 6c9fe55c1..338328b02 100644
--- a/Terminal.Gui/Views/Wizard/Wizard.cs
+++ b/Terminal.Gui/Views/Wizard/Wizard.cs
@@ -386,7 +386,7 @@ public class Wizard : Dialog
///
///
///
- public override bool OnProcessKeyDown (Key key)
+ protected override bool OnProcessKeyDown (Key key)
{
//// BUGBUG: Why is this not handled by a key binding???
if (!Modal)
diff --git a/UICatalog/Scenarios/LineDrawing.cs b/UICatalog/Scenarios/LineDrawing.cs
index 5b2887c59..d2fdb7800 100644
--- a/UICatalog/Scenarios/LineDrawing.cs
+++ b/UICatalog/Scenarios/LineDrawing.cs
@@ -121,7 +121,7 @@ public class LineDrawing : Scenario
tools.CurrentColor = canvas.GetNormalColor ();
canvas.CurrentAttribute = tools.CurrentColor;
- win.KeyDown += (s, e) => { e.Handled = canvas.OnKeyDown (e); };
+ win.KeyDown += (s, e) => { e.Handled = canvas.NewKeyDownEvent (e); };
Application.Run (win);
win.Dispose ();
@@ -290,7 +290,7 @@ public class DrawingArea : View
}
//// BUGBUG: Why is this not handled by a key binding???
- public override bool OnKeyDown (Key e)
+ protected override bool OnKeyDown (Key e)
{
// BUGBUG: These should be implemented with key bindings
if (e.KeyCode == (KeyCode.Z | KeyCode.CtrlMask))
diff --git a/UICatalog/Scenarios/Snake.cs b/UICatalog/Scenarios/Snake.cs
index 0a16aed95..998969d8d 100644
--- a/UICatalog/Scenarios/Snake.cs
+++ b/UICatalog/Scenarios/Snake.cs
@@ -357,7 +357,7 @@ public class Snake : Scenario
}
// BUGBUG: Should (can) this use key bindings instead.
- public override bool OnKeyDown (Key keyEvent)
+ protected override bool OnKeyDown (Key keyEvent)
{
if (keyEvent.KeyCode == KeyCode.CursorUp)
{
diff --git a/UICatalog/Scenarios/VkeyPacketSimulator.cs b/UICatalog/Scenarios/VkeyPacketSimulator.cs
index 94a8618fe..6bea34c91 100644
--- a/UICatalog/Scenarios/VkeyPacketSimulator.cs
+++ b/UICatalog/Scenarios/VkeyPacketSimulator.cs
@@ -112,7 +112,7 @@ public class VkeyPacketSimulator : Scenario
if (handled == null || handled == false)
{
- if (!tvOutput.OnProcessKeyDown (e))
+ if (!tvOutput.NewKeyDownEvent (e))
{
Application.Invoke (
() => MessageBox.Query (
diff --git a/UnitTests/FileServices/FileDialogTests.cs b/UnitTests/FileServices/FileDialogTests.cs
index f446f5be9..28e81ef60 100644
--- a/UnitTests/FileServices/FileDialogTests.cs
+++ b/UnitTests/FileServices/FileDialogTests.cs
@@ -140,7 +140,7 @@ public class FileDialogTests ()
AssertIsTheStartingDirectory (dlg.Path);
Assert.IsType (dlg.MostFocused);
- Send ('v', ConsoleKey.DownArrow);
+ Application.OnKeyDown (Key.CursorDown);
var tv = GetTableView(dlg);
tv.SetFocus ();
@@ -152,15 +152,17 @@ public class FileDialogTests ()
AssertIsTheStartingDirectory (dlg.Path);
// Accept navigation up a directory
- Send ('\n', ConsoleKey.Enter);
+ Application.OnKeyDown (Key.Enter);
AssertIsTheRootDirectory (dlg.Path);
Assert.True (dlg.Canceled);
Assert.False (selected);
- // Now press the back button (in table view)
- Send ('<', ConsoleKey.Backspace);
+ Assert.IsType (dlg.MostFocused);
+
+ // Now press Backspace (in table view)
+ Application.OnKeyDown (Key.Backspace);
// Should move us back to the root
AssertIsTheStartingDirectory (dlg.Path);
diff --git a/UnitTests/Input/ResponderTests.cs b/UnitTests/Input/ResponderTests.cs
index cd02fa0ed..cac5c549e 100644
--- a/UnitTests/Input/ResponderTests.cs
+++ b/UnitTests/Input/ResponderTests.cs
@@ -205,11 +205,11 @@ public class ResponderTests
var r = new View ();
var args = new Key { KeyCode = KeyCode.Null };
- Assert.False (r.OnKeyDown (args));
+ Assert.False (r.NewKeyDownEvent (args));
Assert.False (args.Handled);
r.KeyDown += (s, a) => a.Handled = true;
- Assert.True (r.OnKeyDown (args));
+ Assert.True (r.NewKeyDownEvent (args));
Assert.True (args.Handled);
r.Dispose ();
@@ -232,8 +232,8 @@ public class ResponderTests
var r = new View ();
//Assert.False (r.OnKeyDown (new KeyEventArgs () { Key = Key.Unknown }));
- Assert.False (r.OnKeyDown (new Key { KeyCode = KeyCode.Null }));
- Assert.False (r.OnKeyUp (new Key { KeyCode = KeyCode.Null }));
+ Assert.False (r.NewKeyDownEvent (new Key { KeyCode = KeyCode.Null }));
+ Assert.False (r.NewKeyDownEvent (new Key { KeyCode = KeyCode.Null }));
Assert.False (r.NewMouseEvent (new MouseEvent { Flags = MouseFlags.AllEvents }));
var v = new View ();
@@ -293,6 +293,6 @@ public class ResponderTests
public class DerivedView : View
{
- public override bool OnKeyDown (Key keyEvent) { return true; }
+ protected override bool OnKeyDown (Key keyEvent) { return true; }
}
}
diff --git a/UnitTests/View/KeyboardEventTests.cs b/UnitTests/View/KeyboardEventTests.cs
index 70965a8da..d60e4ec35 100644
--- a/UnitTests/View/KeyboardEventTests.cs
+++ b/UnitTests/View/KeyboardEventTests.cs
@@ -463,7 +463,7 @@ public class KeyboardEventTests (ITestOutputHelper output) : TestsAllViews
return CancelVirtualMethods;
}
- public override bool OnKeyDown (Key keyEvent)
+ protected override bool OnKeyDown (Key keyEvent)
{
OnKeyDownCalled = true;
@@ -477,7 +477,7 @@ public class KeyboardEventTests (ITestOutputHelper output) : TestsAllViews
return CancelVirtualMethods;
}
- public override bool OnProcessKeyDown (Key keyEvent)
+ protected override bool OnProcessKeyDown (Key keyEvent)
{
if (base.OnProcessKeyDown (keyEvent))
{
diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs
index 6f1392a46..54b9b31b5 100644
--- a/UnitTests/View/ViewTests.cs
+++ b/UnitTests/View/ViewTests.cs
@@ -870,10 +870,10 @@ At 0,0
{
var r = new View ();
- Assert.False (r.OnKeyDown (new () { KeyCode = KeyCode.Null }));
+ Assert.False (r.NewKeyDownEvent (Key.Empty));
//Assert.False (r.OnKeyDown (new KeyEventArgs () { Key = Key.Unknown }));
- Assert.False (r.OnKeyUp (new () { KeyCode = KeyCode.Null }));
+ Assert.False (r.NewKeyUpEvent (Key.Empty));
Assert.False (r.NewMouseEvent (new () { Flags = MouseFlags.AllEvents }));
r.Dispose ();
@@ -1132,7 +1132,7 @@ At 0,0
ClearNeedsDisplay ();
}
- public override bool OnKeyDown (Key keyEvent)
+ protected override bool OnKeyDown (Key keyEvent)
{
IsKeyDown = true;
@@ -1146,7 +1146,7 @@ At 0,0
return true;
}
- public override bool OnProcessKeyDown (Key keyEvent)
+ protected override bool OnProcessKeyDown (Key keyEvent)
{
IsKeyPress = true;
diff --git a/UnitTests/Views/ScrollViewTests.cs b/UnitTests/Views/ScrollViewTests.cs
index fd207e28f..b179cd0ca 100644
--- a/UnitTests/Views/ScrollViewTests.cs
+++ b/UnitTests/Views/ScrollViewTests.cs
@@ -579,7 +579,7 @@ public class ScrollViewTests (ITestOutputHelper output)
Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.CursorRight));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
top.Draw ();
expected = @"
@@ -603,7 +603,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.CursorRight));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
top.Draw ();
expected = @"
@@ -627,7 +627,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.CursorRight));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
top.Draw ();
expected = @"
@@ -651,7 +651,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.CursorRight));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
top.Draw ();
expected = @"
@@ -675,7 +675,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.CursorRight));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
top.Draw ();
expected = @"
@@ -699,7 +699,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.CursorRight));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
top.Draw ();
expected = @"
@@ -723,7 +723,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.CursorRight));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorRight));
top.Draw ();
expected = @"
@@ -746,7 +746,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.End.WithCtrl));
+ Assert.True (scrollView.NewKeyDownEvent (Key.End.WithCtrl));
top.Draw ();
expected = @"
@@ -769,8 +769,8 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.Home.WithCtrl));
- Assert.True (scrollView.OnKeyDown (Key.CursorDown));
+ Assert.True (scrollView.NewKeyDownEvent (Key.Home.WithCtrl));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorDown));
top.Draw ();
expected = @"
@@ -793,7 +793,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.CursorDown));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorDown));
top.Draw ();
expected = @"
@@ -816,7 +816,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.CursorDown));
+ Assert.True (scrollView.NewKeyDownEvent (Key.CursorDown));
top.Draw ();
expected = @"
@@ -839,7 +839,7 @@ public class ScrollViewTests (ITestOutputHelper output)
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (1, 1, 21, 14), pos);
- Assert.True (scrollView.OnKeyDown (Key.End));
+ Assert.True (scrollView.NewKeyDownEvent (Key.End));
top.Draw ();
expected = @"
@@ -940,120 +940,120 @@ public class ScrollViewTests (ITestOutputHelper output)
Assert.True (sv.KeepContentAlwaysInViewport);
Assert.True (sv.AutoHideScrollBars);
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.CursorUp));
+ Assert.False (sv.NewKeyDownEvent (Key.CursorUp));
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.CursorDown));
+ Assert.True (sv.NewKeyDownEvent (Key.CursorDown));
Assert.Equal (new (0, -1), sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.CursorUp));
+ Assert.True (sv.NewKeyDownEvent (Key.CursorUp));
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.PageUp));
+ Assert.False (sv.NewKeyDownEvent (Key.PageUp));
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.PageDown));
+ Assert.True (sv.NewKeyDownEvent (Key.PageDown));
Point point0xMinus10 = new (0, -10);
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.PageDown));
+ Assert.False (sv.NewKeyDownEvent (Key.PageDown));
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.CursorDown));
+ Assert.False (sv.NewKeyDownEvent (Key.CursorDown));
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.V.WithAlt));
+ Assert.True (sv.NewKeyDownEvent (Key.V.WithAlt));
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.V.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.V.WithCtrl));
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.CursorLeft));
+ Assert.False (sv.NewKeyDownEvent (Key.CursorLeft));
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.CursorRight));
+ Assert.True (sv.NewKeyDownEvent (Key.CursorRight));
Assert.Equal (new (-1, -10), sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.CursorLeft));
+ Assert.True (sv.NewKeyDownEvent (Key.CursorLeft));
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.PageUp.WithCtrl));
+ Assert.False (sv.NewKeyDownEvent (Key.PageUp.WithCtrl));
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.PageDown.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.PageDown.WithCtrl));
Point pointMinus20xMinus10 = new (-20, -10);
Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.CursorRight));
+ Assert.False (sv.NewKeyDownEvent (Key.CursorRight));
Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.Home));
+ Assert.True (sv.NewKeyDownEvent (Key.Home));
Point pointMinus20x0 = new (-20, 0);
Assert.Equal (pointMinus20x0, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.Home));
+ Assert.False (sv.NewKeyDownEvent (Key.Home));
Assert.Equal (pointMinus20x0, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.End));
+ Assert.True (sv.NewKeyDownEvent (Key.End));
Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.End));
+ Assert.False (sv.NewKeyDownEvent (Key.End));
Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.Home.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.Home.WithCtrl));
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.Home.WithCtrl));
+ Assert.False (sv.NewKeyDownEvent (Key.Home.WithCtrl));
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.End.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.End.WithCtrl));
Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.End.WithCtrl));
+ Assert.False (sv.NewKeyDownEvent (Key.End.WithCtrl));
Assert.Equal (pointMinus20xMinus10, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.Home));
+ Assert.True (sv.NewKeyDownEvent (Key.Home));
Assert.Equal (pointMinus20x0, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.Home.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.Home.WithCtrl));
Assert.Equal (Point.Empty, sv.ContentOffset);
sv.KeepContentAlwaysInViewport = false;
Assert.False (sv.KeepContentAlwaysInViewport);
Assert.True (sv.AutoHideScrollBars);
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.CursorUp));
+ Assert.False (sv.NewKeyDownEvent (Key.CursorUp));
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.CursorDown));
+ Assert.True (sv.NewKeyDownEvent (Key.CursorDown));
Assert.Equal (new (0, -1), sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.CursorUp));
+ Assert.True (sv.NewKeyDownEvent (Key.CursorUp));
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.PageUp));
+ Assert.False (sv.NewKeyDownEvent (Key.PageUp));
Assert.Equal (Point.Empty, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.PageDown));
+ Assert.True (sv.NewKeyDownEvent (Key.PageDown));
Assert.Equal (point0xMinus10, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.PageDown));
+ Assert.True (sv.NewKeyDownEvent (Key.PageDown));
Point point0xMinus19 = new (0, -19);
Assert.Equal (point0xMinus19, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.PageDown));
+ Assert.False (sv.NewKeyDownEvent (Key.PageDown));
Assert.Equal (point0xMinus19, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.CursorDown));
+ Assert.False (sv.NewKeyDownEvent (Key.CursorDown));
Assert.Equal (point0xMinus19, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.V.WithAlt));
+ Assert.True (sv.NewKeyDownEvent (Key.V.WithAlt));
Assert.Equal (new (0, -9), sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.V.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.V.WithCtrl));
Assert.Equal (point0xMinus19, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.CursorLeft));
+ Assert.False (sv.NewKeyDownEvent (Key.CursorLeft));
Assert.Equal (point0xMinus19, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.CursorRight));
+ Assert.True (sv.NewKeyDownEvent (Key.CursorRight));
Assert.Equal (new (-1, -19), sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.CursorLeft));
+ Assert.True (sv.NewKeyDownEvent (Key.CursorLeft));
Assert.Equal (point0xMinus19, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.PageUp.WithCtrl));
+ Assert.False (sv.NewKeyDownEvent (Key.PageUp.WithCtrl));
Assert.Equal (point0xMinus19, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.PageDown.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.PageDown.WithCtrl));
Assert.Equal (new (-20, -19), sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.PageDown.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.PageDown.WithCtrl));
Point pointMinus39xMinus19 = new (-39, -19);
Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.PageDown.WithCtrl));
+ Assert.False (sv.NewKeyDownEvent (Key.PageDown.WithCtrl));
Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.CursorRight));
+ Assert.False (sv.NewKeyDownEvent (Key.CursorRight));
Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.PageUp.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.PageUp.WithCtrl));
var pointMinus19xMinus19 = new Point (-19, -19);
Assert.Equal (pointMinus19xMinus19, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.Home));
+ Assert.True (sv.NewKeyDownEvent (Key.Home));
Assert.Equal (new (-19, 0), sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.Home));
+ Assert.False (sv.NewKeyDownEvent (Key.Home));
Assert.Equal (new (-19, 0), sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.End));
+ Assert.True (sv.NewKeyDownEvent (Key.End));
Assert.Equal (pointMinus19xMinus19, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.End));
+ Assert.False (sv.NewKeyDownEvent (Key.End));
Assert.Equal (pointMinus19xMinus19, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.Home.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.Home.WithCtrl));
Assert.Equal (point0xMinus19, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.Home.WithCtrl));
+ Assert.False (sv.NewKeyDownEvent (Key.Home.WithCtrl));
Assert.Equal (point0xMinus19, sv.ContentOffset);
- Assert.True (sv.OnKeyDown (Key.End.WithCtrl));
+ Assert.True (sv.NewKeyDownEvent (Key.End.WithCtrl));
Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
- Assert.False (sv.OnKeyDown (Key.End.WithCtrl));
+ Assert.False (sv.NewKeyDownEvent (Key.End.WithCtrl));
Assert.Equal (pointMinus39xMinus19, sv.ContentOffset);
}