Răsfoiți Sursa

Application.Keyboard Code cleanup

Tig 9 luni în urmă
părinte
comite
f536945df5

+ 1 - 1
Terminal.Gui/Application/Application.Initialization.cs

@@ -178,7 +178,7 @@ public static partial class Application // Initialization (Init/Shutdown)
     }
 
     private static void Driver_SizeChanged (object? sender, SizeChangedEventArgs e) { OnSizeChanging (e); }
-    private static void Driver_KeyDown (object? sender, Key e) { OnKeyDown (e); }
+    private static void Driver_KeyDown (object? sender, Key e) { RaiseKeyDownEvent (e); }
     private static void Driver_KeyUp (object? sender, Key e) { OnKeyUp (e); }
     private static void Driver_MouseEvent (object? sender, MouseEvent e) { OnMouseEvent (e); }
 

+ 63 - 179
Terminal.Gui/Application/Application.Keyboard.cs

@@ -3,91 +3,16 @@ namespace Terminal.Gui;
 
 public static partial class Application // Keyboard handling
 {
-    private static Key _nextTabGroupKey = Key.F6; // Resources/config.json overrrides
-    private static Key _nextTabKey = Key.Tab; // Resources/config.json overrrides
-    private static Key _prevTabGroupKey = Key.F6.WithShift; // Resources/config.json overrrides
-    private static Key _prevTabKey = Key.Tab.WithShift; // Resources/config.json overrrides
-    private static Key _quitKey = Key.Esc; // Resources/config.json overrrides
-    private static Key _arrangeKey = Key.F5.WithCtrl; // Resources/config.json overrrides
-
-    static Application () { AddApplicationKeyBindings (); }
-
-    /// <summary>Gets the key bindings for this view.</summary>
-    public static KeyBindings KeyBindings { get; internal set; } = new ();
-
-    /// <summary>
-    ///     Event fired when the user presses a key. Fired by <see cref="OnKeyDown"/>.
-    ///     <para>
-    ///         Set <see cref="Key.Handled"/> to <see langword="true"/> to indicate the key was handled and to prevent
-    ///         additional processing.
-    ///     </para>
-    /// </summary>
-    /// <remarks>
-    ///     All drivers support firing the <see cref="KeyDown"/> event. Some drivers (Curses) do not support firing the
-    ///     <see cref="KeyDown"/> and <see cref="KeyUp"/> events.
-    ///     <para>Fired after <see cref="KeyDown"/> and before <see cref="KeyUp"/>.</para>
-    /// </remarks>
-    public static event EventHandler<Key>? KeyDown;
-
-    /// <summary>
-    ///     Event fired when the user releases a key. Fired by <see cref="OnKeyUp"/>.
-    ///     <para>
-    ///         Set <see cref="Key.Handled"/> to <see langword="true"/> to indicate the key was handled and to prevent
-    ///         additional processing.
-    ///     </para>
-    /// </summary>
-    /// <remarks>
-    ///     All drivers support firing the <see cref="KeyDown"/> event. Some drivers (Curses) do not support firing the
-    ///     <see cref="KeyDown"/> and <see cref="KeyUp"/> events.
-    ///     <para>Fired after <see cref="KeyDown"/>.</para>
-    /// </remarks>
-    public static event EventHandler<Key>? KeyUp;
-
-    /// <summary>Alternative key to navigate forwards through views. Ctrl+Tab is the primary key.</summary>
-    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
-    public static Key NextTabGroupKey
-    {
-        get => _nextTabGroupKey;
-        set
-        {
-            if (_nextTabGroupKey != value)
-            {
-                ReplaceKey (_nextTabGroupKey, value);
-                _nextTabGroupKey = value;
-            }
-        }
-    }
-
-    /// <summary>Alternative key to navigate forwards through views. Ctrl+Tab is the primary key.</summary>
-    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
-    public static Key NextTabKey
-    {
-        get => _nextTabKey;
-        set
-        {
-            if (_nextTabKey != value)
-            {
-                ReplaceKey (_nextTabKey, value);
-                _nextTabKey = value;
-            }
-        }
-    }
-
     /// <summary>
-    ///     Called by the <see cref="ConsoleDriver"/> when the user presses a key. Fires the <see cref="KeyDown"/> event
-    ///     then calls <see cref="View.NewKeyDownEvent"/> on all top level views. Called after <see cref="OnKeyDown"/> and
-    ///     before <see cref="OnKeyUp"/>.
+    ///     Called when the user presses a key (by the <see cref="ConsoleDriver"/>). Raises the cancelable
+    ///     <see cref="KeyDown"/> event
+    ///     then calls <see cref="View.NewKeyDownEvent"/> on all top level views. Called before <see cref="RaiseKeyUpEvent"/>.
     /// </summary>
     /// <remarks>Can be used to simulate key press events.</remarks>
     /// <param name="keyEvent"></param>
     /// <returns><see langword="true"/> if the key was handled.</returns>
-    public static bool OnKeyDown (Key keyEvent)
+    public static bool RaiseKeyDownEvent (Key keyEvent)
     {
-        //if (!IsInitialized)
-        //{
-        //    return true;
-        //}
-
         KeyDown?.Invoke (null, keyEvent);
 
         if (keyEvent.Handled)
@@ -150,43 +75,50 @@ public static partial class Application // Keyboard handling
         }
 
         return false;
-    }
 
-    /// <summary>
-    ///     INTENRAL method to invoke one of the commands in <see cref="CommandImplementations"/>
-    /// </summary>
-    /// <param name="command"></param>
-    /// <param name="keyEvent"></param>
-    /// <param name="appBinding"></param>
-    /// <returns></returns>
-    /// <exception cref="NotSupportedException"></exception>
-    private static bool? InvokeCommand (Command command, Key keyEvent, KeyBinding appBinding)
-    {
-        if (!CommandImplementations!.ContainsKey (command))
+        static bool? InvokeCommand (Command command, Key keyEvent, KeyBinding appBinding)
         {
-            throw new NotSupportedException (
-                                             @$"A KeyBinding was set up for the command {command} ({keyEvent}) but that command is not supported by Application."
-                                            );
-        }
+            if (!CommandImplementations!.ContainsKey (command))
+            {
+                throw new NotSupportedException (
+                                                 @$"A KeyBinding was set up for the command {command} ({keyEvent}) but that command is not supported by Application."
+                                                );
+            }
 
-        if (CommandImplementations.TryGetValue (command, out View.CommandImplementation? implementation))
-        {
-            var context = new CommandContext (command, keyEvent, appBinding); // Create the context here
+            if (CommandImplementations.TryGetValue (command, out View.CommandImplementation? implementation))
+            {
+                var context = new CommandContext (command, keyEvent, appBinding); // Create the context here
 
-            return implementation (context);
-        }
+                return implementation (context);
+            }
 
-        return false;
+            return false;
+        }
     }
 
     /// <summary>
-    ///     Called by the <see cref="ConsoleDriver"/> when the user releases a key. Fires the <see cref="KeyUp"/> event
-    ///     then calls <see cref="View.NewKeyUpEvent"/> on all top level views. Called after <see cref="OnKeyDown"/>.
+    ///     Raised when the user presses a key.
+    ///     <para>
+    ///         Set <see cref="Key.Handled"/> to <see langword="true"/> to indicate the key was handled and to prevent
+    ///         additional processing.
+    ///     </para>
     /// </summary>
-    /// <remarks>Can be used to simulate key press events.</remarks>
+    /// <remarks>
+    ///     All drivers support firing the <see cref="KeyDown"/> event. Some drivers (Curses) do not support firing the
+    ///     <see cref="KeyDown"/> and <see cref="KeyUp"/> events.
+    ///     <para>Fired after <see cref="KeyDown"/> and before <see cref="KeyUp"/>.</para>
+    /// </remarks>
+    public static event EventHandler<Key>? KeyDown;
+
+    /// <summary>
+    ///     Called when the user releases a key (by the <see cref="ConsoleDriver"/>). Raises the cancelable <see cref="KeyUp"/>
+    ///     event
+    ///     then calls <see cref="View.NewKeyUpEvent"/> on all top level views. Called after <see cref="RaiseKeyDownEvent"/>.
+    /// </summary>
+    /// <remarks>Can be used to simulate key release events.</remarks>
     /// <param name="a"></param>
     /// <returns><see langword="true"/> if the key was handled.</returns>
-    public static bool OnKeyUp (Key a)
+    public static bool RaiseKeyUpEvent (Key a)
     {
         if (!IsInitialized)
         {
@@ -216,65 +148,12 @@ public static partial class Application // Keyboard handling
         return false;
     }
 
-    /// <summary>Alternative key to navigate backwards through views. Shift+Ctrl+Tab is the primary key.</summary>
-    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
-    public static Key PrevTabGroupKey
-    {
-        get => _prevTabGroupKey;
-        set
-        {
-            if (_prevTabGroupKey != value)
-            {
-                ReplaceKey (_prevTabGroupKey, value);
-                _prevTabGroupKey = value;
-            }
-        }
-    }
-
-    /// <summary>Alternative key to navigate backwards through views. Shift+Ctrl+Tab is the primary key.</summary>
-    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
-    public static Key PrevTabKey
-    {
-        get => _prevTabKey;
-        set
-        {
-            if (_prevTabKey != value)
-            {
-                ReplaceKey (_prevTabKey, value);
-                _prevTabKey = value;
-            }
-        }
-    }
+    #region Application-scoped KeyBindings
 
-    /// <summary>Gets or sets the key to quit the application.</summary>
-    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
-    public static Key QuitKey
-    {
-        get => _quitKey;
-        set
-        {
-            if (_quitKey != value)
-            {
-                ReplaceKey (_quitKey, value);
-                _quitKey = value;
-            }
-        }
-    }
+    static Application () { AddApplicationKeyBindings (); }
 
-    /// <summary>Gets or sets the key to activate arranging views using the keyboard.</summary>
-    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
-    public static Key ArrangeKey
-    {
-        get => _arrangeKey;
-        set
-        {
-            if (_arrangeKey != value)
-            {
-                ReplaceKey (_arrangeKey, value);
-                _arrangeKey = value;
-            }
-        }
-    }
+    /// <summary>Gets the Application-scoped key bindings.</summary>
+    public static KeyBindings KeyBindings { get; internal set; } = new ();
 
     internal static void AddApplicationKeyBindings ()
     {
@@ -286,6 +165,7 @@ public static partial class Application // Keyboard handling
                     static () =>
                     {
                         RequestStop ();
+
                         return true;
                     }
                    );
@@ -348,7 +228,7 @@ public static partial class Application // Keyboard handling
 
         KeyBindings.Clear ();
 
-        // Resources/config.json overrrides
+        // Resources/config.json overrides
         NextTabKey = Key.Tab;
         PrevTabKey = Key.Tab.WithShift;
         NextTabGroupKey = Key.F6;
@@ -397,6 +277,26 @@ public static partial class Application // Keyboard handling
                           .ToList ();
     }
 
+    private static void ReplaceKey (Key oldKey, Key newKey)
+    {
+        if (KeyBindings.Bindings.Count == 0)
+        {
+            return;
+        }
+
+        if (newKey == Key.Empty)
+        {
+            KeyBindings.Remove (oldKey);
+        }
+        else
+        {
+            KeyBindings.ReplaceKey (oldKey, newKey);
+        }
+    }
+
+
+    #endregion Application-scoped KeyBindings
+
     /// <summary>
     ///     <para>
     ///         Sets the function that will be invoked for a <see cref="Command"/>.
@@ -420,20 +320,4 @@ public static partial class Application // Keyboard handling
     /// </summary>
     private static Dictionary<Command, View.CommandImplementation>? CommandImplementations { get; set; }
 
-    private static void ReplaceKey (Key oldKey, Key newKey)
-    {
-        if (KeyBindings.Bindings.Count == 0)
-        {
-            return;
-        }
-
-        if (newKey == Key.Empty)
-        {
-            KeyBindings.Remove (oldKey);
-        }
-        else
-        {
-            KeyBindings.ReplaceKey (oldKey, newKey);
-        }
-    }
 }

+ 35 - 0
Terminal.Gui/Application/Application.Run.cs

@@ -6,6 +6,41 @@ namespace Terminal.Gui;
 
 public static partial class Application // Run (Begin, Run, End, Stop)
 {
+    private static Key _quitKey = Key.Esc; // Resources/config.json overrides
+
+    /// <summary>Gets or sets the key to quit the application.</summary>
+    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
+    public static Key QuitKey
+    {
+        get => _quitKey;
+        set
+        {
+            if (_quitKey != value)
+            {
+                ReplaceKey (_quitKey, value);
+                _quitKey = value;
+            }
+        }
+    }
+
+    private static Key _arrangeKey = Key.F5.WithCtrl; // Resources/config.json overrides
+
+
+    /// <summary>Gets or sets the key to activate arranging views using the keyboard.</summary>
+    [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
+    public static Key ArrangeKey
+    {
+        get => _arrangeKey;
+        set
+        {
+            if (_arrangeKey != value)
+            {
+                ReplaceKey (_arrangeKey, value);
+                _arrangeKey = value;
+            }
+        }
+    }
+
     // When `End ()` is called, it is possible `RunState.Toplevel` is a different object than `Top`.
     // This variable is set in `End` in this case so that `Begin` correctly sets `Top`.
     private static Toplevel? _cachedRunStateToplevel;

+ 14 - 12
Terminal.Gui/View/View.Keyboard.cs

@@ -1,6 +1,5 @@
 #nullable enable
 using System.Diagnostics;
-using Microsoft.CodeAnalysis.FlowAnalysis;
 
 namespace Terminal.Gui;
 
@@ -266,7 +265,7 @@ public partial class View // Keyboard APIs
     ///     <para>
     ///         Calling this method for a key bound to the view via an Application-scoped keybinding will have no effect.
     ///         Instead,
-    ///         use <see cref="Application.OnKeyDown"/>.
+    ///         use <see cref="Application.NewKeyDown"/>.
     ///     </para>
     ///     <para>See <see href="../docs/keyboard.md">for an overview of Terminal.Gui keyboard APIs.</see></para>
     /// </remarks>
@@ -337,7 +336,8 @@ public partial class View // Keyboard APIs
 
     /// <summary>
     ///     Called when the user presses a key, allowing subscribers to pre-process the key down event. Called
-    ///     before <see cref="InvokingKeyBindings"/> and <see cref="KeyDownNotHandled"/> are raised. Set <see cref="Key.Handled"/>
+    ///     before <see cref="InvokingKeyBindings"/> and <see cref="KeyDownNotHandled"/> are raised. Set
+    ///     <see cref="Key.Handled"/>
     ///     to true to
     ///     stop the key from being processed further.
     /// </summary>
@@ -357,7 +357,8 @@ public partial class View // Keyboard APIs
 
     /// <summary>
     ///     Raised when the user presses a key, allowing subscribers to pre-process the key down event. Called
-    ///     before <see cref="InvokingKeyBindings"/> and <see cref="KeyDownNotHandled"/> are raised. Set <see cref="Key.Handled"/>
+    ///     before <see cref="InvokingKeyBindings"/> and <see cref="KeyDownNotHandled"/> are raised. Set
+    ///     <see cref="Key.Handled"/>
     ///     to true to
     ///     stop the key from being processed further.
     /// </summary>
@@ -507,14 +508,17 @@ public partial class View // Keyboard APIs
     private Dictionary<Command, CommandImplementation> CommandImplementations { get; } = new ();
 
     /// <summary>
-    ///     INTERNAL API: Raises the <see cref="InvokingKeyBindings"/> event and invokes the commands bound to <paramref name="key"/>.
+    ///     INTERNAL API: Raises the <see cref="InvokingKeyBindings"/> event and invokes the commands bound to
+    ///     <paramref name="key"/>.
     /// </summary>
     /// <param name="key"></param>
     /// <returns>
-    ///     <see langword="null"/> if no command was invoked or there was no matching key binding; input processing should continue.
+    ///     <see langword="null"/> if no command was invoked or there was no matching key binding; input processing should
+    ///     continue.
     ///     <see langword="false"/> if a command was invoked and was not handled (or cancelled); input processing should
     ///     continue.
-    ///     <see langword="true"/> if <see cref="InvokingKeyBindings"/> was handled or a command was invoked and handled (or cancelled); input processing should stop.
+    ///     <see langword="true"/> if <see cref="InvokingKeyBindings"/> was handled or a command was invoked and handled (or
+    ///     cancelled); input processing should stop.
     /// </returns>
     internal bool? RaiseInvokingKeyBindingsAndInvokeCommands (Key key)
     {
@@ -590,10 +594,7 @@ public partial class View // Keyboard APIs
     ///     continue.
     ///     <see langword="true"/> if the event was raised and handled (or cancelled); input processing should stop.
     /// </returns>
-    protected virtual bool OnInvokingKeyBindings (Key key, KeyBindingScope scope)
-    {
-        return false;
-    }
+    protected virtual bool OnInvokingKeyBindings (Key key, KeyBindingScope scope) { return false; }
 
     // TODO: This does not carry KeyBindingScope, but OnInvokingKeyBindings does
     /// <summary>
@@ -722,7 +723,8 @@ public partial class View // Keyboard APIs
     ///     <see langword="null"/> if no command was invoked; input processing should continue.
     ///     <see langword="false"/> if at least one command was invoked and was not handled (or cancelled); input processing
     ///     should continue.
-    ///     <see langword="true"/> if at least one command was invoked and handled (or cancelled); input processing should stop.
+    ///     <see langword="true"/> if at least one command was invoked and handled (or cancelled); input processing should
+    ///     stop.
     /// </returns>
     protected bool? InvokeCommands (Key key, KeyBindingScope scope)
     {

+ 29 - 29
UnitTests/Application/KeyboardTests.cs

@@ -64,14 +64,14 @@ public class KeyboardTests
         Assert.True (win2.HasFocus);
         Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
 
-        Application.OnKeyDown (Key.F6);
+        Application.NewKeyDown (Key.F6);
         Assert.True (win2.CanFocus);
         Assert.False (win.HasFocus);
         Assert.True (win2.CanFocus);
         Assert.True (win2.HasFocus);
         Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
 
-        Application.OnKeyDown (Key.F6);
+        Application.NewKeyDown (Key.F6);
         Assert.False (win.CanFocus);
         Assert.False (win.HasFocus);
         Assert.True (win2.CanFocus);
@@ -117,14 +117,14 @@ public class KeyboardTests
         Assert.False (win2.HasFocus);
         Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
 
-        Application.OnKeyDown (Key.F6);
+        Application.NewKeyDown (Key.F6);
         Assert.True (win.CanFocus);
         Assert.False (win.HasFocus);
         Assert.True (win2.CanFocus);
         Assert.True (win2.HasFocus);
         Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
 
-        Application.OnKeyDown (Key.F6);
+        Application.NewKeyDown (Key.F6);
         Assert.True (win.CanFocus);
         Assert.True (win.HasFocus);
         Assert.True (win2.CanFocus);
@@ -170,31 +170,31 @@ public class KeyboardTests
         top.Add (view);
         Application.Begin (top);
 
-        Application.OnKeyDown (Key.A);
+        Application.NewKeyDown (Key.A);
         Assert.False (invoked);
         Assert.True (view.ApplicationCommand);
 
         invoked = false;
         view.ApplicationCommand = false;
         Application.KeyBindings.Remove (KeyCode.A);
-        Application.OnKeyDown (Key.A); // old
+        Application.NewKeyDown (Key.A); // old
         Assert.False (invoked);
         Assert.False (view.ApplicationCommand);
         Application.KeyBindings.Add (Key.A.WithCtrl, view, Command.Save);
-        Application.OnKeyDown (Key.A); // old
+        Application.NewKeyDown (Key.A); // old
         Assert.False (invoked);
         Assert.False (view.ApplicationCommand);
-        Application.OnKeyDown (Key.A.WithCtrl); // new
+        Application.NewKeyDown (Key.A.WithCtrl); // new
         Assert.False (invoked);
         Assert.True (view.ApplicationCommand);
 
         invoked = false;
-        Application.OnKeyDown (Key.H);
+        Application.NewKeyDown (Key.H);
         Assert.True (invoked);
 
         invoked = false;
         Assert.False (view.HasFocus);
-        Application.OnKeyDown (Key.F);
+        Application.NewKeyDown (Key.F);
         Assert.False (invoked);
 
         Assert.True (view.ApplicationCommand);
@@ -215,7 +215,7 @@ public class KeyboardTests
         top.Add (view);
         Application.Begin (top);
 
-        Application.OnKeyDown (Key.A.WithCtrl);
+        Application.NewKeyDown (Key.A.WithCtrl);
         Assert.False (invoked);
         Assert.False (view.ApplicationCommand);
         Assert.False (view.HotKeyCommand);
@@ -223,7 +223,7 @@ public class KeyboardTests
 
         invoked = false;
         Assert.False (view.HasFocus);
-        Application.OnKeyDown (Key.Z);
+        Application.NewKeyDown (Key.Z);
         Assert.False (invoked);
         Assert.False (view.ApplicationCommand);
         Assert.False (view.HotKeyCommand);
@@ -399,7 +399,7 @@ public class KeyboardTests
         Assert.True (subView1.HasFocus);
 
         // Act
-        Application.OnKeyDown (Application.NextTabGroupKey);
+        Application.NewKeyDown (Application.NextTabGroupKey);
 
         // Assert
         Assert.True (view2.HasFocus);
@@ -432,24 +432,24 @@ public class KeyboardTests
                                      Assert.True (v1.HasFocus);
 
                                      // Across TabGroups
-                                     Application.OnKeyDown (Key.F6);
+                                     Application.NewKeyDown (Key.F6);
                                      Assert.True (v3.HasFocus);
-                                     Application.OnKeyDown (Key.F6);
+                                     Application.NewKeyDown (Key.F6);
                                      Assert.True (v1.HasFocus);
 
-                                     Application.OnKeyDown (Key.F6.WithShift);
+                                     Application.NewKeyDown (Key.F6.WithShift);
                                      Assert.True (v3.HasFocus);
-                                     Application.OnKeyDown (Key.F6.WithShift);
+                                     Application.NewKeyDown (Key.F6.WithShift);
                                      Assert.True (v1.HasFocus);
 
                                      // Restore?
-                                     Application.OnKeyDown (Key.Tab);
+                                     Application.NewKeyDown (Key.Tab);
                                      Assert.True (v2.HasFocus);
 
-                                     Application.OnKeyDown (Key.F6);
+                                     Application.NewKeyDown (Key.F6);
                                      Assert.True (v3.HasFocus);
 
-                                     Application.OnKeyDown (Key.F6);
+                                     Application.NewKeyDown (Key.F6);
                                      Assert.True (v1.HasFocus);
 
                                      Application.RequestStop ();
@@ -485,7 +485,7 @@ public class KeyboardTests
         view1.SetFocus ();
 
         // Act
-        Application.OnKeyDown (Application.NextTabKey);
+        Application.NewKeyDown (Application.NextTabKey);
 
         // Assert
         Assert.True (view2.HasFocus);
@@ -539,7 +539,7 @@ public class KeyboardTests
         Assert.True (subView1.HasFocus);
 
         // Act
-        Application.OnKeyDown (Application.PrevTabGroupKey);
+        Application.NewKeyDown (Application.PrevTabGroupKey);
 
         // Assert
         Assert.True (view2.HasFocus);
@@ -562,7 +562,7 @@ public class KeyboardTests
         view1.SetFocus ();
 
         // Act
-        Application.OnKeyDown (Application.NextTabKey);
+        Application.NewKeyDown (Application.NextTabKey);
 
         // Assert
         Assert.True (view2.HasFocus);
@@ -605,21 +605,21 @@ public class KeyboardTests
 
         Key prevKey = Application.QuitKey;
 
-        Application.OnKeyDown (Application.QuitKey);
+        Application.NewKeyDown (Application.QuitKey);
         Assert.True (isQuiting);
 
         isQuiting = false;
-        Application.OnKeyDown (Application.QuitKey);
+        Application.NewKeyDown (Application.QuitKey);
         Assert.True (isQuiting);
 
         isQuiting = false;
         Application.QuitKey = Key.C.WithCtrl;
-        Application.OnKeyDown (prevKey); // Should not quit
+        Application.NewKeyDown (prevKey); // Should not quit
         Assert.False (isQuiting);
-        Application.OnKeyDown (Key.Q.WithCtrl); // Should not quit
+        Application.NewKeyDown (Key.Q.WithCtrl); // Should not quit
         Assert.False (isQuiting);
 
-        Application.OnKeyDown (Application.QuitKey);
+        Application.NewKeyDown (Application.QuitKey);
         Assert.True (isQuiting);
 
         // Reset the QuitKey to avoid throws errors on another tests
@@ -728,7 +728,7 @@ public class KeyboardTests
             if (Application.IsInitialized)
             {
                 _output.WriteLine ("  Pressing QuitKey");
-                Application.OnKeyDown (Application.QuitKey);
+                Application.NewKeyDown (Application.QuitKey);
             }
         }
     }

+ 5 - 5
UnitTests/Dialogs/MessageBoxTests.cs

@@ -33,14 +33,14 @@ public class MessageBoxTests
 
                                          case 2:
                                              // Tab to btn2
-                                             Application.OnKeyDown (Key.Tab);
+                                             Application.RaiseKeyDownEvent (Key.Tab);
 
                                              Button btn = Application.Navigation!.GetFocused () as Button;
 
                                              btn.Accepting += (sender, e) => { btnAcceptCount++; };
 
                                              // Click
-                                             Application.OnKeyDown (Key.Enter);
+                                             Application.RaiseKeyDownEvent (Key.Enter);
 
                                              break;
 
@@ -77,7 +77,7 @@ public class MessageBoxTests
                                              break;
 
                                          case 2:
-                                             Application.OnKeyDown (Key.Esc);
+                                             Application.RaiseKeyDownEvent (Key.Esc);
 
                                              break;
 
@@ -116,13 +116,13 @@ public class MessageBoxTests
 
                                          case 2:
                                              // Tab to btn2
-                                             Application.OnKeyDown (Key.Tab);
+                                             Application.RaiseKeyDownEvent (Key.Tab);
 
                                              Button btn = Application.Navigation!.GetFocused () as Button;
 
                                              btn.Accepting += (sender, e) => { btnAcceptCount++; };
 
-                                             Application.OnKeyDown (Key.Space);
+                                             Application.RaiseKeyDownEvent (Key.Space);
 
                                              break;
 

+ 3 - 3
UnitTests/FileServices/FileDialogTests.cs

@@ -140,7 +140,7 @@ public class FileDialogTests ()
         AssertIsTheStartingDirectory (dlg.Path);
 
         Assert.IsType<TextField> (dlg.MostFocused);
-        Application.OnKeyDown (Key.CursorDown);
+        Application.RaiseKeyDownEvent (Key.CursorDown);
 
         var tv = GetTableView(dlg);
         tv.SetFocus ();
@@ -152,7 +152,7 @@ public class FileDialogTests ()
         AssertIsTheStartingDirectory (dlg.Path);
 
         // Accept navigation up a directory
-        Application.OnKeyDown (Key.Enter);
+        Application.RaiseKeyDownEvent (Key.Enter);
 
         AssertIsTheRootDirectory (dlg.Path);
 
@@ -162,7 +162,7 @@ public class FileDialogTests ()
         Assert.IsType<TableView> (dlg.MostFocused);
 
         // Now press Backspace (in table view)
-        Application.OnKeyDown (Key.Backspace);
+        Application.RaiseKeyDownEvent (Key.Backspace);
 
         // Should move us back to the root
         AssertIsTheStartingDirectory (dlg.Path);

+ 1 - 1
UnitTests/UICatalog/ScenarioTests.cs

@@ -132,7 +132,7 @@ public class ScenarioTests : TestsAllViews
             {
                 // Press QuitKey 
                 //_output.WriteLine ($"Forcing Quit with {Application.QuitKey}");
-                Application.OnKeyDown (Application.QuitKey);
+                Application.NewKeyDown (Application.QuitKey);
             }
         }
     }

+ 3 - 3
UnitTests/View/HotKeyTests.cs

@@ -362,20 +362,20 @@ public class HotKeyTests
         view.Selecting += (s, e) => selectRaised = true;
 
         Assert.Equal (KeyCode.T, view.HotKey);
-        Assert.True (Application.OnKeyDown (Key.T)); 
+        Assert.True (Application.RaiseKeyDownEvent (Key.T)); 
         Assert.True (hotKeyRaised);
         Assert.False (acceptRaised);
         Assert.False (selectRaised);
 
         hotKeyRaised = false;
-        Assert.True (Application.OnKeyDown (Key.T.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.T.WithAlt));
         Assert.True (hotKeyRaised);
         Assert.False (acceptRaised);
         Assert.False (selectRaised);
 
         hotKeyRaised = false;
         view.HotKey = KeyCode.E;
-        Assert.True (Application.OnKeyDown (Key.E.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.E.WithAlt));
         Assert.True (hotKeyRaised);
         Assert.False (acceptRaised);
         Assert.False (selectRaised);

+ 1 - 1
UnitTests/View/Navigation/CanFocusTests.cs

@@ -354,7 +354,7 @@ public class CanFocusTests () : TestsAllViews
         Assert.False (label.HasFocus);
         Assert.True (view.HasFocus);
 
-        Assert.True (Application.OnKeyDown (Key.Tab));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Tab));
         Assert.True (label.HasFocus);
         Assert.False (view.HasFocus);
 

+ 11 - 11
UnitTests/View/Navigation/NavigationTests.cs

@@ -59,17 +59,17 @@ public class NavigationTests (ITestOutputHelper _output) : TestsAllViews
                 case TabBehavior.TabStop:
                 case TabBehavior.NoStop:
                 case TabBehavior.TabGroup:
-                    Application.OnKeyDown (key);
+                    Application.RaiseKeyDownEvent (key);
 
                     if (view.HasFocus)
                     {
                         // Try once more (HexView)
-                        Application.OnKeyDown (key);
+                        Application.RaiseKeyDownEvent (key);
                     }
 
                     break;
                 default:
-                    Application.OnKeyDown (Key.Tab);
+                    Application.RaiseKeyDownEvent (Key.Tab);
 
                     break;
             }
@@ -178,18 +178,18 @@ public class NavigationTests (ITestOutputHelper _output) : TestsAllViews
                 case null:
                 case TabBehavior.NoStop:
                 case TabBehavior.TabStop:
-                    if (Application.OnKeyDown (Key.Tab))
+                    if (Application.RaiseKeyDownEvent (Key.Tab))
                     {
                         if (view.HasFocus)
                         {
                             // Try another nav key (e.g. for TextView that eats Tab)
-                            Application.OnKeyDown (Key.CursorDown);
+                            Application.RaiseKeyDownEvent (Key.CursorDown);
                         }
                     };
                     break;
 
                 case TabBehavior.TabGroup:
-                    Application.OnKeyDown (Key.F6);
+                    Application.RaiseKeyDownEvent (Key.F6);
 
                     break;
                 default:
@@ -211,18 +211,18 @@ public class NavigationTests (ITestOutputHelper _output) : TestsAllViews
 
                 break;
             case TabBehavior.TabStop:
-                Application.OnKeyDown (Key.Tab);
+                Application.RaiseKeyDownEvent (Key.Tab);
 
                 break;
             case TabBehavior.TabGroup:
-                if (!Application.OnKeyDown (Key.F6))
+                if (!Application.RaiseKeyDownEvent (Key.F6))
                 {
                     view.SetFocus ();
                 }
 
                 break;
             case null:
-                Application.OnKeyDown (Key.Tab);
+                Application.RaiseKeyDownEvent (Key.Tab);
 
                 break;
             default:
@@ -308,12 +308,12 @@ public class NavigationTests (ITestOutputHelper _output) : TestsAllViews
         Assert.Equal (0, hasFocusChangingCount);
         Assert.Equal (0, hasFocusChangedCount);
 
-        Application.OnKeyDown (Key.Tab);
+        Application.RaiseKeyDownEvent (Key.Tab);
 
         Assert.Equal (0, hasFocusChangingCount);
         Assert.Equal (0, hasFocusChangedCount);
 
-        Application.OnKeyDown (Key.F6);
+        Application.RaiseKeyDownEvent (Key.F6);
 
         Assert.Equal (0, hasFocusChangingCount);
         Assert.Equal (0, hasFocusChangedCount);

+ 11 - 11
UnitTests/View/ViewKeyBindingTests.cs

@@ -18,17 +18,17 @@ public class ViewKeyBindingTests (ITestOutputHelper output)
         top.Add (view);
         Application.Begin (top);
 
-        Application.OnKeyDown (Key.A);
+        Application.RaiseKeyDownEvent (Key.A);
         Assert.False (invoked);
         Assert.True (view.ApplicationCommand);
 
         invoked = false;
-        Application.OnKeyDown (Key.H);
+        Application.RaiseKeyDownEvent (Key.H);
         Assert.True (invoked);
 
         invoked = false;
         Assert.False (view.HasFocus);
-        Application.OnKeyDown (Key.F);
+        Application.RaiseKeyDownEvent (Key.F);
         Assert.False (invoked);
         Assert.False (view.FocusedCommand);
 
@@ -36,7 +36,7 @@ public class ViewKeyBindingTests (ITestOutputHelper output)
         view.CanFocus = true;
         view.SetFocus ();
         Assert.True (view.HasFocus);
-        Application.OnKeyDown (Key.F);
+        Application.RaiseKeyDownEvent (Key.F);
         Assert.True (invoked);
 
         Assert.True (view.ApplicationCommand);
@@ -57,7 +57,7 @@ public class ViewKeyBindingTests (ITestOutputHelper output)
         top.Add (view);
         Application.Begin (top);
 
-        Application.OnKeyDown (Key.Z);
+        Application.RaiseKeyDownEvent (Key.Z);
         Assert.False (invoked);
         Assert.False (view.ApplicationCommand);
         Assert.False (view.HotKeyCommand);
@@ -65,7 +65,7 @@ public class ViewKeyBindingTests (ITestOutputHelper output)
 
         invoked = false;
         Assert.False (view.HasFocus);
-        Application.OnKeyDown (Key.F);
+        Application.RaiseKeyDownEvent (Key.F);
         Assert.False (invoked);
         Assert.False (view.ApplicationCommand);
         Assert.False (view.HotKeyCommand);
@@ -86,18 +86,18 @@ public class ViewKeyBindingTests (ITestOutputHelper output)
         Application.Begin (top);
 
         invoked = false;
-        Application.OnKeyDown (Key.H);
+        Application.RaiseKeyDownEvent (Key.H);
         Assert.True (invoked);
         Assert.True (view.HotKeyCommand);
 
         view.HotKey = KeyCode.Z;
         invoked = false;
         view.HotKeyCommand = false;
-        Application.OnKeyDown (Key.H); // old hot key
+        Application.RaiseKeyDownEvent (Key.H); // old hot key
         Assert.False (invoked);
         Assert.False (view.HotKeyCommand);
 
-        Application.OnKeyDown (Key.Z); // new hot key
+        Application.RaiseKeyDownEvent (Key.Z); // new hot key
         Assert.True (invoked);
         Assert.True (view.HotKeyCommand);
         top.Dispose ();
@@ -115,12 +115,12 @@ public class ViewKeyBindingTests (ITestOutputHelper output)
         top.Add (view);
         Application.Begin (top);
 
-        Application.OnKeyDown (Key.Z);
+        Application.RaiseKeyDownEvent (Key.Z);
         Assert.False (invoked);
         Assert.False (view.HotKeyCommand);
 
         invoked = false;
-        Application.OnKeyDown (Key.F);
+        Application.RaiseKeyDownEvent (Key.F);
         Assert.False (view.HotKeyCommand);
         top.Dispose ();
     }

+ 6 - 6
UnitTests/Views/ButtonTests.cs

@@ -376,7 +376,7 @@ public class ButtonTests (ITestOutputHelper output)
         Assert.True (btn.HasFocus);
 
         // default keybinding is Space which results in Command.Accept (when focused)
-        Application.OnKeyDown (new ((KeyCode)' '));
+        Application.RaiseKeyDownEvent (new ((KeyCode)' '));
         Assert.Equal (1, pressed);
 
         // remove the default keybinding (Space)
@@ -384,26 +384,26 @@ public class ButtonTests (ITestOutputHelper output)
         btn.KeyBindings.Clear (Command.Accept);
 
         // After clearing the default keystroke the Space button no longer does anything for the Button
-        Application.OnKeyDown (new ((KeyCode)' '));
+        Application.RaiseKeyDownEvent (new ((KeyCode)' '));
         Assert.Equal (1, pressed);
 
         // Set a new binding of b for the click (Accept) event
         btn.KeyBindings.Add (Key.B, Command.HotKey); // b will now trigger the Accept command (when focused or not)
 
         // now pressing B should call the button click event
-        Application.OnKeyDown (Key.B);
+        Application.RaiseKeyDownEvent (Key.B);
         Assert.Equal (2, pressed);
 
         // now pressing Shift-B should NOT call the button click event
-        Application.OnKeyDown (Key.B.WithShift);
+        Application.RaiseKeyDownEvent (Key.B.WithShift);
         Assert.Equal (2, pressed);
 
         // now pressing Alt-B should NOT call the button click event
-        Application.OnKeyDown (Key.B.WithAlt);
+        Application.RaiseKeyDownEvent (Key.B.WithAlt);
         Assert.Equal (2, pressed);
 
         // now pressing Shift-Alt-B should NOT call the button click event
-        Application.OnKeyDown (Key.B.WithAlt.WithShift);
+        Application.RaiseKeyDownEvent (Key.B.WithAlt.WithShift);
         Assert.Equal (2, pressed);
         top.Dispose ();
     }

+ 23 - 23
UnitTests/Views/ColorPickerTests.cs

@@ -64,14 +64,14 @@ public class ColorPickerTests
 
         cp.Draw ();
 
-        Application.OnKeyDown (Key.CursorRight);
+        Application.RaiseKeyDownEvent (Key.CursorRight);
 
         cp.Draw ();
 
         Assert.Equal (3, r.TrianglePosition);
         Assert.Equal ("#0F0000", hex.Text);
 
-        Application.OnKeyDown (Key.CursorRight);
+        Application.RaiseKeyDownEvent (Key.CursorRight);
 
         cp.Draw ();
 
@@ -81,7 +81,7 @@ public class ColorPickerTests
         // Use cursor to move the triangle all the way to the right
         for (int i = 0; i < 1000; i++)
         {
-            Application.OnKeyDown (Key.CursorRight);
+            Application.RaiseKeyDownEvent (Key.CursorRight);
         }
 
         cp.Draw ();
@@ -713,19 +713,19 @@ public class ColorPickerTests
         name.Text = "";
         Assert.Empty (name.Text);
 
-        Application.OnKeyDown (Key.A);
-        Application.OnKeyDown (Key.Q);
+        Application.RaiseKeyDownEvent (Key.A);
+        Application.RaiseKeyDownEvent (Key.Q);
 
         Assert.Equal ("aq", name.Text);
 
 
         // Auto complete the color name
-        Application.OnKeyDown (Key.Tab);
+        Application.RaiseKeyDownEvent (Key.Tab);
 
         Assert.Equal ("Aquamarine", name.Text);
 
         // Tab out of the text field
-        Application.OnKeyDown (Key.Tab);
+        Application.RaiseKeyDownEvent (Key.Tab);
 
         Assert.False (name.HasFocus);
         Assert.NotSame (name, cp.Focused);
@@ -761,24 +761,24 @@ public class ColorPickerTests
         Assert.Empty (hex.Text);
         Assert.Empty (name.Text);
 
-        Application.OnKeyDown ('#');
+        Application.RaiseKeyDownEvent ('#');
         Assert.Empty (name.Text);
         //7FFFD4
 
         Assert.Equal ("#", hex.Text);
-        Application.OnKeyDown ('7');
-        Application.OnKeyDown ('F');
-        Application.OnKeyDown ('F');
-        Application.OnKeyDown ('F');
-        Application.OnKeyDown ('D');
+        Application.RaiseKeyDownEvent ('7');
+        Application.RaiseKeyDownEvent ('F');
+        Application.RaiseKeyDownEvent ('F');
+        Application.RaiseKeyDownEvent ('F');
+        Application.RaiseKeyDownEvent ('D');
         Assert.Empty (name.Text);
 
-        Application.OnKeyDown ('4');
+        Application.RaiseKeyDownEvent ('4');
 
         Assert.True (hex.HasFocus);
 
         // Tab out of the hex field - should wrap to first focusable subview 
-        Application.OnKeyDown (Key.Tab);
+        Application.RaiseKeyDownEvent (Key.Tab);
         Assert.False (hex.HasFocus);
         Assert.NotSame (hex, cp.Focused);
 
@@ -819,24 +819,24 @@ public class ColorPickerTests
         Assert.Empty (hex.Text);
         Assert.Empty (name.Text);
 
-        Application.OnKeyDown ('#');
+        Application.RaiseKeyDownEvent ('#');
         Assert.Empty (name.Text);
         //7FFFD4
 
         Assert.Equal ("#", hex.Text);
-        Application.OnKeyDown ('7');
-        Application.OnKeyDown ('F');
-        Application.OnKeyDown ('F');
-        Application.OnKeyDown ('F');
-        Application.OnKeyDown ('D');
+        Application.RaiseKeyDownEvent ('7');
+        Application.RaiseKeyDownEvent ('F');
+        Application.RaiseKeyDownEvent ('F');
+        Application.RaiseKeyDownEvent ('F');
+        Application.RaiseKeyDownEvent ('D');
         Assert.Empty (name.Text);
 
-        Application.OnKeyDown ('4');
+        Application.RaiseKeyDownEvent ('4');
 
         Assert.True (hex.HasFocus);
 
         // Should stay in the hex field (because accept not tab)
-        Application.OnKeyDown (Key.Enter);
+        Application.RaiseKeyDownEvent (Key.Enter);
         Assert.True (hex.HasFocus);
         Assert.Same (hex, cp.Focused);
 

+ 44 - 44
UnitTests/Views/ComboBoxTests.cs

@@ -105,13 +105,13 @@ public class ComboBoxTests (ITestOutputHelper output)
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.NotNull (cb.Source);
         Assert.True (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.Null (cb.Source);
         Assert.False (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
@@ -155,7 +155,7 @@ public class ComboBoxTests (ITestOutputHelper output)
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.Equal ("Two", selected);
         Assert.True (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
@@ -166,7 +166,7 @@ public class ComboBoxTests (ITestOutputHelper output)
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.Esc));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Esc));
         Assert.Equal ("Two", selected);
         Assert.False (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
@@ -202,7 +202,7 @@ public class ComboBoxTests (ITestOutputHelper output)
         Assert.Equal ("One", cb.Text);
 
         Assert.True (cb.Subviews [1].NewKeyDownEvent (Key.CursorDown));
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.Equal ("Two", selected);
         Assert.False (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
@@ -251,7 +251,7 @@ public class ComboBoxTests (ITestOutputHelper output)
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.Equal ("Two", selected);
         Assert.True (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
@@ -262,7 +262,7 @@ public class ComboBoxTests (ITestOutputHelper output)
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.Esc));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Esc));
         Assert.Equal ("Two", selected);
         Assert.False (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
@@ -417,7 +417,7 @@ public class ComboBoxTests (ITestOutputHelper output)
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
 
         Assert.True (
                      cb.Subviews [1]
@@ -441,7 +441,7 @@ public class ComboBoxTests (ITestOutputHelper output)
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
 
         Assert.True (
                      cb.Subviews [1]
@@ -465,7 +465,7 @@ public class ComboBoxTests (ITestOutputHelper output)
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
 
         Assert.True (
                      cb.Subviews [1]
@@ -595,7 +595,7 @@ Three ",
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.Equal ("Three", selected);
         Assert.True (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
@@ -646,7 +646,7 @@ Three ",
                                                attributes
                                               );
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.Equal ("Three", selected);
         Assert.False (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
@@ -756,7 +756,7 @@ Three ",
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.Equal ("Two", selected);
         Assert.True (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
@@ -767,7 +767,7 @@ Three ",
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
 
-        Assert.True (Application.OnKeyDown (Key.Esc));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Esc));
         Assert.Equal ("Two", selected);
         Assert.False (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
@@ -803,7 +803,7 @@ Three ",
         Assert.Equal ("", cb.Text);
 
         Assert.True (cb.Subviews [1].NewKeyDownEvent (Key.CursorDown));
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.Equal ("", selected);
         Assert.False (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
@@ -834,32 +834,32 @@ Three ",
 
         cb.OpenSelectedItem += (s, _) => opened = true;
 
-        Assert.False (Application.OnKeyDown (Key.Enter));
+        Assert.False (Application.RaiseKeyDownEvent (Key.Enter));
         Assert.False (opened);
 
         cb.Text = "Tw";
-        Assert.False (Application.OnKeyDown (Key.Enter));
+        Assert.False (Application.RaiseKeyDownEvent (Key.Enter));
         Assert.True (opened);
         Assert.Equal ("Tw", cb.Text);
         Assert.False (cb.IsShow);
 
         cb.SetSource<string> (null);
         Assert.False (cb.IsShow);
-        Assert.False (Application.OnKeyDown (Key.Enter));
-        Assert.True (Application.OnKeyDown (Key.F4)); // with no source also expand empty
+        Assert.False (Application.RaiseKeyDownEvent (Key.Enter));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4)); // with no source also expand empty
         Assert.True (cb.IsShow);
 
         Assert.Equal (-1, cb.SelectedItem);
         cb.SetSource (source);
         cb.Text = "";
-        Assert.True (Application.OnKeyDown (Key.F4)); // collapse
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4)); // collapse
         Assert.False (cb.IsShow);
-        Assert.True (Application.OnKeyDown (Key.F4)); // expand
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4)); // expand
         Assert.True (cb.IsShow);
         cb.Collapse ();
         Assert.False (cb.IsShow);
         Assert.True (cb.HasFocus);
-        Assert.True (Application.OnKeyDown (Key.CursorDown)); // losing focus
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorDown)); // losing focus
         Assert.False (cb.IsShow);
         Assert.False (cb.HasFocus);
         cb.SetFocus ();
@@ -870,27 +870,27 @@ Three ",
         Assert.True (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.CursorDown));
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorDown));
         Assert.True (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.CursorDown));
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorDown));
         Assert.True (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.CursorDown));
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorDown));
         Assert.True (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.CursorUp));
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorUp));
         Assert.True (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.CursorUp));
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorUp));
         Assert.True (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.CursorUp));
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorUp));
         Assert.True (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
@@ -904,7 +904,7 @@ One
                                                       output
                                                      );
 
-        Assert.True (Application.OnKeyDown (Key.PageDown));
+        Assert.True (Application.RaiseKeyDownEvent (Key.PageDown));
         Assert.True (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
@@ -919,7 +919,7 @@ Two
                                                       output
                                                      );
 
-        Assert.True (Application.OnKeyDown (Key.PageDown));
+        Assert.True (Application.RaiseKeyDownEvent (Key.PageDown));
         Assert.True (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
@@ -933,43 +933,43 @@ Three
 ",
                                                       output
                                                      );
-        Assert.True (Application.OnKeyDown (Key.PageUp));
+        Assert.True (Application.RaiseKeyDownEvent (Key.PageUp));
         Assert.True (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.PageUp));
+        Assert.True (Application.RaiseKeyDownEvent (Key.PageUp));
         Assert.True (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.False (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.End));
+        Assert.True (Application.RaiseKeyDownEvent (Key.End));
         Assert.False (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.Home));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Home));
         Assert.False (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.True (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.End));
+        Assert.True (Application.RaiseKeyDownEvent (Key.End));
         Assert.True (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.Home));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Home));
         Assert.True (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.Esc));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Esc));
         Assert.False (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.CursorDown)); // losing focus
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorDown)); // losing focus
         Assert.False (cb.HasFocus);
         Assert.False (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
@@ -980,7 +980,7 @@ Three
         Assert.False (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.U.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.U.WithCtrl));
         Assert.True (cb.HasFocus);
         Assert.True (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
@@ -1009,7 +1009,7 @@ Three
         source.Add ("One");
         Assert.Equal (1, cb.Source.Count);
         Assert.Equal (-1, cb.SelectedItem);
-        Assert.True (Application.OnKeyDown (Key.F4));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F4));
         Assert.True (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
@@ -1020,12 +1020,12 @@ Three
         Assert.True (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("T", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.Enter));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Enter));
         Assert.False (cb.IsShow);
         Assert.Equal (2, cb.Source.Count);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("T", cb.Text);
-        Assert.True (Application.OnKeyDown (Key.Esc));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Esc));
         Assert.False (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem); // retains last accept selected item
         Assert.Equal ("", cb.Text); // clear text

+ 41 - 41
UnitTests/Views/ContextMenuTests.cs

@@ -400,9 +400,9 @@ public class ContextMenuTests (ITestOutputHelper output)
         top.Add (tf);
         Application.Begin (top);
 
-        Assert.True (Application.OnKeyDown (ContextMenu.DefaultKey));
+        Assert.True (Application.RaiseKeyDownEvent (ContextMenu.DefaultKey));
         Assert.True (tf.ContextMenu.MenuBar!.IsMenuOpen);
-        Assert.True (Application.OnKeyDown (ContextMenu.DefaultKey));
+        Assert.True (Application.RaiseKeyDownEvent (ContextMenu.DefaultKey));
 
         // The last context menu bar opened is always preserved
         Assert.NotNull (tf.ContextMenu.MenuBar);
@@ -1473,9 +1473,9 @@ public class ContextMenuTests (ITestOutputHelper output)
         Application.Begin (top);
 
         Assert.Null (cm.MenuBar);
-        Assert.False (Application.OnKeyDown (Key.N.WithCtrl));
-        Assert.False (Application.OnKeyDown (Key.R.WithCtrl));
-        Assert.False (Application.OnKeyDown (Key.D.WithCtrl));
+        Assert.False (Application.RaiseKeyDownEvent (Key.N.WithCtrl));
+        Assert.False (Application.RaiseKeyDownEvent (Key.R.WithCtrl));
+        Assert.False (Application.RaiseKeyDownEvent (Key.D.WithCtrl));
         Assert.False (newFile);
         Assert.False (renameFile);
         Assert.False (deleteFile);
@@ -1485,17 +1485,17 @@ public class ContextMenuTests (ITestOutputHelper output)
         Assert.True (cm.MenuBar.KeyBindings.Bindings.ContainsKey (Key.R.WithCtrl));
         Assert.True (cm.MenuBar.KeyBindings.Bindings.ContainsKey (Key.D.WithCtrl));
 
-        Assert.True (Application.OnKeyDown (Key.N.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.True (newFile);
         Assert.False (cm.MenuBar!.IsMenuOpen);
         cm.Show (menuItems);
-        Assert.True (Application.OnKeyDown (Key.R.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.R.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.True (renameFile);
         Assert.False (cm.MenuBar.IsMenuOpen);
         cm.Show (menuItems);
-        Assert.True (Application.OnKeyDown (Key.D.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.D.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.True (deleteFile);
         Assert.False (cm.MenuBar.IsMenuOpen);
@@ -1507,9 +1507,9 @@ public class ContextMenuTests (ITestOutputHelper output)
         newFile = false;
         renameFile = false;
         deleteFile = false;
-        Assert.False (Application.OnKeyDown (Key.N.WithCtrl));
-        Assert.False (Application.OnKeyDown (Key.R.WithCtrl));
-        Assert.False (Application.OnKeyDown (Key.D.WithCtrl));
+        Assert.False (Application.RaiseKeyDownEvent (Key.N.WithCtrl));
+        Assert.False (Application.RaiseKeyDownEvent (Key.R.WithCtrl));
+        Assert.False (Application.RaiseKeyDownEvent (Key.D.WithCtrl));
         Assert.False (newFile);
         Assert.False (renameFile);
         Assert.False (deleteFile);
@@ -1557,8 +1557,8 @@ public class ContextMenuTests (ITestOutputHelper output)
         Assert.False (menuBar.KeyBindings.Bindings.ContainsKey (Key.R.WithCtrl));
         Assert.Null (cm.MenuBar);
 
-        Assert.True (Application.OnKeyDown (Key.N.WithCtrl));
-        Assert.False (Application.OnKeyDown (Key.R.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithCtrl));
+        Assert.False (Application.RaiseKeyDownEvent (Key.R.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.True (newFile);
         Assert.False (renameFile);
@@ -1572,12 +1572,12 @@ public class ContextMenuTests (ITestOutputHelper output)
         Assert.True (cm.MenuBar.KeyBindings.Bindings.ContainsKey (Key.R.WithCtrl));
 
         Assert.True (cm.MenuBar.IsMenuOpen);
-        Assert.True (Application.OnKeyDown (Key.N.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.True (newFile);
         Assert.False (cm.MenuBar!.IsMenuOpen);
         cm.Show (menuItems);
-        Assert.True (Application.OnKeyDown (Key.R.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.R.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.True (renameFile);
         Assert.False (cm.MenuBar.IsMenuOpen);
@@ -1589,8 +1589,8 @@ public class ContextMenuTests (ITestOutputHelper output)
 
         newFile = false;
         renameFile = false;
-        Assert.True (Application.OnKeyDown (Key.N.WithCtrl));
-        Assert.False (Application.OnKeyDown (Key.R.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithCtrl));
+        Assert.False (Application.RaiseKeyDownEvent (Key.R.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.True (newFile);
         Assert.False (renameFile);
@@ -1635,7 +1635,7 @@ public class ContextMenuTests (ITestOutputHelper output)
         Assert.True (menuBar.KeyBindings.Bindings.ContainsKey (Key.N.WithCtrl));
         Assert.Null (cm.MenuBar);
 
-        Assert.True (Application.OnKeyDown (Key.N.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.True (newMenuBar);
         Assert.False (newContextMenu);
@@ -1647,7 +1647,7 @@ public class ContextMenuTests (ITestOutputHelper output)
         Assert.True (cm.MenuBar!.KeyBindings.Bindings.ContainsKey (Key.N.WithCtrl));
 
         Assert.True (cm.MenuBar.IsMenuOpen);
-        Assert.True (Application.OnKeyDown (Key.N.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.False (newMenuBar);
 
@@ -1660,7 +1660,7 @@ public class ContextMenuTests (ITestOutputHelper output)
 
         newMenuBar = false;
         newContextMenu = false;
-        Assert.True (Application.OnKeyDown (Key.N.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithCtrl));
         Application.MainLoop!.RunIteration ();
         Assert.True (newMenuBar);
         Assert.False (newContextMenu);
@@ -1693,9 +1693,9 @@ public class ContextMenuTests (ITestOutputHelper output)
         Application.Begin (top);
 
         Assert.Null (cm.MenuBar);
-        Assert.False (Application.OnKeyDown (Key.N.WithAlt));
-        Assert.False (Application.OnKeyDown (Key.R.WithAlt));
-        Assert.False (Application.OnKeyDown (Key.D.WithAlt));
+        Assert.False (Application.RaiseKeyDownEvent (Key.N.WithAlt));
+        Assert.False (Application.RaiseKeyDownEvent (Key.R.WithAlt));
+        Assert.False (Application.RaiseKeyDownEvent (Key.D.WithAlt));
         Assert.False (newFile);
         Assert.False (renameFile);
         Assert.False (deleteFile);
@@ -1717,17 +1717,17 @@ public class ContextMenuTests (ITestOutputHelper output)
         Assert.True (menus [0].KeyBindings.Bindings.ContainsKey (Key.D.WithAlt));
         Assert.True (menus [0].KeyBindings.Bindings.ContainsKey (Key.D.NoShift));
 
-        Assert.True (Application.OnKeyDown (Key.N.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithAlt));
         Assert.False (cm.MenuBar!.IsMenuOpen);
         Application.MainLoop!.RunIteration ();
         Assert.True (newFile);
         cm.Show (menuItems);
-        Assert.True (Application.OnKeyDown (Key.R.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.R.WithAlt));
         Assert.False (cm.MenuBar.IsMenuOpen);
         Application.MainLoop!.RunIteration ();
         Assert.True (renameFile);
         cm.Show (menuItems);
-        Assert.True (Application.OnKeyDown (Key.D.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.D.WithAlt));
         Assert.False (cm.MenuBar.IsMenuOpen);
         Application.MainLoop!.RunIteration ();
         Assert.True (deleteFile);
@@ -1742,9 +1742,9 @@ public class ContextMenuTests (ITestOutputHelper output)
         newFile = false;
         renameFile = false;
         deleteFile = false;
-        Assert.False (Application.OnKeyDown (Key.N.WithAlt));
-        Assert.False (Application.OnKeyDown (Key.R.WithAlt));
-        Assert.False (Application.OnKeyDown (Key.D.WithAlt));
+        Assert.False (Application.RaiseKeyDownEvent (Key.N.WithAlt));
+        Assert.False (Application.RaiseKeyDownEvent (Key.R.WithAlt));
+        Assert.False (Application.RaiseKeyDownEvent (Key.D.WithAlt));
         Assert.False (newFile);
         Assert.False (renameFile);
         Assert.False (deleteFile);
@@ -1801,14 +1801,14 @@ public class ContextMenuTests (ITestOutputHelper output)
         Assert.Empty (menus);
         Assert.Null (cm.MenuBar);
 
-        Assert.True (Application.OnKeyDown (Key.F.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F.WithAlt));
         Assert.True (menuBar.IsMenuOpen);
         Assert.Equal (2, Application.Top!.Subviews.Count);
         menus = Application.Top!.Subviews.Where (v => v is Menu m && m.Host == menuBar).ToArray ();
         Assert.True (menus [0].KeyBindings.Bindings.ContainsKey (Key.N.WithAlt));
-        Assert.True (Application.OnKeyDown (Key.N.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithAlt));
         Assert.False (menuBar.IsMenuOpen);
-        Assert.False (Application.OnKeyDown (Key.R.WithAlt));
+        Assert.False (Application.RaiseKeyDownEvent (Key.R.WithAlt));
         Application.MainLoop!.RunIteration ();
         Assert.True (newFile);
         Assert.False (renameFile);
@@ -1840,9 +1840,9 @@ public class ContextMenuTests (ITestOutputHelper output)
         Assert.True (menus [1].KeyBindings.Bindings.ContainsKey (Key.R.WithAlt));
         Assert.True (menus [1].KeyBindings.Bindings.ContainsKey (Key.R.NoShift));
         Assert.True (cm.MenuBar.IsMenuOpen);
-        Assert.True (Application.OnKeyDown (Key.F.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F.WithAlt));
         Assert.False (cm.MenuBar.IsMenuOpen);
-        Assert.True (Application.OnKeyDown (Key.N.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithAlt));
         Application.MainLoop!.RunIteration ();
         Assert.True (newFile);
 
@@ -1858,8 +1858,8 @@ public class ContextMenuTests (ITestOutputHelper output)
         Assert.False (menus [1].KeyBindings.Bindings.ContainsKey (Key.E.NoShift));
         Assert.True (menus [1].KeyBindings.Bindings.ContainsKey (Key.R.WithAlt));
         Assert.True (menus [1].KeyBindings.Bindings.ContainsKey (Key.R.NoShift));
-        Assert.True (Application.OnKeyDown (Key.E.NoShift));
-        Assert.True (Application.OnKeyDown (Key.R.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.E.NoShift));
+        Assert.True (Application.RaiseKeyDownEvent (Key.R.WithAlt));
         Assert.False (cm.MenuBar.IsMenuOpen);
         Application.MainLoop!.RunIteration ();
         Assert.True (renameFile);
@@ -1876,9 +1876,9 @@ public class ContextMenuTests (ITestOutputHelper output)
 
         newFile = false;
         renameFile = false;
-        Assert.True (Application.OnKeyDown (Key.F.WithAlt));
-        Assert.True (Application.OnKeyDown (Key.N.WithAlt));
-        Assert.False (Application.OnKeyDown (Key.R.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.N.WithAlt));
+        Assert.False (Application.RaiseKeyDownEvent (Key.R.WithAlt));
         Application.MainLoop!.RunIteration ();
         Assert.True (newFile);
         Assert.False (renameFile);
@@ -1923,14 +1923,14 @@ public class ContextMenuTests (ITestOutputHelper output)
         top.Add (menuBar);
         Application.Begin (top);
 
-        Assert.True (Application.OnKeyDown (Key.F.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F.WithAlt));
         Assert.True (menuBar.IsMenuOpen);
 
         cm.Show (menuItems);
         Assert.False (menuBar.IsMenuOpen);
         Assert.True (cm.MenuBar!.IsMenuOpen);
 
-        Assert.True (Application.OnKeyDown (Key.F.WithAlt));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F.WithAlt));
         Assert.True (menuBar.IsMenuOpen);
         Assert.False (cm.MenuBar!.IsMenuOpen);
 

+ 1 - 1
UnitTests/Views/DatePickerTests.cs

@@ -82,7 +82,7 @@ public class DatePickerTests
         Assert.Equal (datePicker.Subviews.First (v => v.Id == "_nextMonthButton"), datePicker.Focused);
 
         // Change month to December
-        Assert.False (Application.OnKeyDown (Key.Enter));
+        Assert.False (Application.RaiseKeyDownEvent (Key.Enter));
         Assert.Equal (12, datePicker.Date.Month);
 
         // Next month button is disabled, so focus advanced to edit field

+ 2 - 2
UnitTests/Views/LabelTests.cs

@@ -1341,7 +1341,7 @@ e
         Application.Top.SetFocus ();
         Assert.True (otherView.HasFocus);
 
-        Assert.True (Application.OnKeyDown (label.HotKey));
+        Assert.True (Application.RaiseKeyDownEvent (label.HotKey));
         Assert.False (otherView.HasFocus);
         Assert.False (label.HasFocus);
         Assert.True (nextView.HasFocus);
@@ -1396,7 +1396,7 @@ e
         Assert.True (view.HasFocus);
 
         // No focused view accepts Tab, and there's no other view to focus, so OnKeyDown returns false
-        Assert.True (Application.OnKeyDown (label.HotKey));
+        Assert.True (Application.RaiseKeyDownEvent (label.HotKey));
         Assert.True (label.HasFocus);
         Assert.False (view.HasFocus);
 

+ 2 - 2
UnitTests/Views/MenuBarTests.cs

@@ -2666,7 +2666,7 @@ Edit
         top.Draw ();
         TestHelpers.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
 
-        Assert.True (Application.OnKeyDown (menu.Key));
+        Assert.True (Application.NewKeyDown (menu.Key));
         Assert.False (menu.IsMenuOpen);
         Assert.True (tf.HasFocus);
         top.Draw ();
@@ -2949,7 +2949,7 @@ Edit
         top.Add (menu);
         Application.Begin (top);
 
-        Application.OnKeyDown (Key.S.WithCtrl);
+        Application.NewKeyDown (Key.S.WithCtrl);
         Application.MainLoop.RunIteration ();
 
         Assert.True (saveAction);

+ 33 - 33
UnitTests/Views/RadioGroupTests.cs

@@ -57,7 +57,7 @@ public class RadioGroupTests (ITestOutputHelper output)
         rg.SetFocus ();
 
         Assert.Equal (-1, rg.SelectedItem);
-        Application.OnKeyDown (Key.Space);
+        Application.NewKeyDown (Key.Space);
         Assert.Equal (0, rg.SelectedItem);
 
         Application.Top.Dispose ();
@@ -105,21 +105,21 @@ public class RadioGroupTests (ITestOutputHelper output)
 
         // With HasFocus
         // Test up/down without Select
-        Assert.False (Application.OnKeyDown (Key.CursorUp)); // Should not change (should focus prev view if there was one, which there isn't)
+        Assert.False (Application.NewKeyDown (Key.CursorUp)); // Should not change (should focus prev view if there was one, which there isn't)
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.Cursor);
         Assert.Equal (0, selectedItemChangedCount);
         Assert.Equal (0, selectingCount);
         Assert.Equal (0, acceptedCount);
 
-        Assert.True (Application.OnKeyDown (Key.CursorDown));
+        Assert.True (Application.NewKeyDown (Key.CursorDown));
         Assert.Equal (0, rg.SelectedItem); // Cursor changed, but selection didnt
         Assert.Equal (1, rg.Cursor);
         Assert.Equal (0, selectedItemChangedCount);
         Assert.Equal (0, selectingCount);
         Assert.Equal (0, acceptedCount);
 
-        Assert.False (Application.OnKeyDown (Key.CursorDown)); // Should not change selection (should focus next view if there was one, which there isn't)
+        Assert.False (Application.NewKeyDown (Key.CursorDown)); // Should not change selection (should focus next view if there was one, which there isn't)
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
         Assert.Equal (0, selectedItemChangedCount);
@@ -127,7 +127,7 @@ public class RadioGroupTests (ITestOutputHelper output)
         Assert.Equal (0, acceptedCount);
 
         // Test Select (Space) when Cursor != SelectedItem - Should select cursor
-        Assert.True (Application.OnKeyDown (Key.Space));
+        Assert.True (Application.NewKeyDown (Key.Space));
         Assert.Equal (1, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
         Assert.Equal (1, selectedItemChangedCount);
@@ -135,34 +135,34 @@ public class RadioGroupTests (ITestOutputHelper output)
         Assert.Equal (0, acceptedCount);
 
         // Test Select (Space) when Cursor == SelectedItem - Should cycle
-        Assert.True (Application.OnKeyDown (Key.Space));
+        Assert.True (Application.NewKeyDown (Key.Space));
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.Cursor);
         Assert.Equal (2, selectedItemChangedCount);
         Assert.Equal (2, selectingCount);
         Assert.Equal (0, acceptedCount);
 
-        Assert.True (Application.OnKeyDown (Key.Space));
+        Assert.True (Application.NewKeyDown (Key.Space));
         Assert.Equal (1, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
-        Assert.True (Application.OnKeyDown (Key.Space));
+        Assert.True (Application.NewKeyDown (Key.Space));
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.Cursor);
-        Assert.True (Application.OnKeyDown (Key.Space));
+        Assert.True (Application.NewKeyDown (Key.Space));
         Assert.Equal (1, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
 
-        Assert.True (Application.OnKeyDown (Key.Home));
+        Assert.True (Application.NewKeyDown (Key.Home));
         Assert.Equal (1, rg.SelectedItem);
         Assert.Equal (0, rg.Cursor);
-        Assert.True (Application.OnKeyDown (Key.Space));
+        Assert.True (Application.NewKeyDown (Key.Space));
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.Cursor);
 
-        Assert.True (Application.OnKeyDown (Key.End));
+        Assert.True (Application.NewKeyDown (Key.End));
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
-        Assert.True (Application.OnKeyDown (Key.Space));
+        Assert.True (Application.NewKeyDown (Key.Space));
         Assert.Equal (1, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
         Assert.Equal (7, selectedItemChangedCount);
@@ -174,7 +174,7 @@ public class RadioGroupTests (ITestOutputHelper output)
 
         rg.HotKey = Key.L;
         Assert.Equal (Key.L, rg.HotKey);
-        Assert.True (Application.OnKeyDown (rg.HotKey));
+        Assert.True (Application.NewKeyDown (rg.HotKey));
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.Cursor);
         Assert.Equal (8, selectedItemChangedCount);
@@ -182,12 +182,12 @@ public class RadioGroupTests (ITestOutputHelper output)
         Assert.Equal (0, acceptedCount);
 
         //     Make Selected != Cursor
-        Assert.True (Application.OnKeyDown (Key.CursorDown));
+        Assert.True (Application.NewKeyDown (Key.CursorDown));
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
 
         //    Selected != Cursor - Raise HotKey event - Since we're focused, this should just advance
-        Assert.True (Application.OnKeyDown (rg.HotKey));
+        Assert.True (Application.NewKeyDown (rg.HotKey));
         Assert.Equal (1, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
         Assert.Equal (9, selectedItemChangedCount);
@@ -239,7 +239,7 @@ public class RadioGroupTests (ITestOutputHelper output)
         //    Selected (0) == Cursor (0) - SetFocus
         rg.HotKey = Key.L;
         Assert.Equal (Key.L, rg.HotKey);
-        Assert.True (Application.OnKeyDown (rg.HotKey));
+        Assert.True (Application.NewKeyDown (rg.HotKey));
         Assert.True (rg.HasFocus);
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.Cursor);
@@ -248,14 +248,14 @@ public class RadioGroupTests (ITestOutputHelper output)
         Assert.Equal (0, acceptCount);
 
         //     Make Selected != Cursor
-        Assert.True (Application.OnKeyDown (Key.CursorDown));
+        Assert.True (Application.NewKeyDown (Key.CursorDown));
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
 
         otherView.SetFocus ();
 
         //    Selected != Cursor - SetFocus
-        Assert.True (Application.OnKeyDown (rg.HotKey));
+        Assert.True (Application.NewKeyDown (rg.HotKey));
         Assert.True (rg.HasFocus);
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
@@ -263,7 +263,7 @@ public class RadioGroupTests (ITestOutputHelper output)
         Assert.Equal (0, selectCount);
         Assert.Equal (0, acceptCount);
 
-        Assert.True (Application.OnKeyDown (rg.HotKey));
+        Assert.True (Application.NewKeyDown (rg.HotKey));
         Assert.True (rg.HasFocus);
         Assert.Equal (1, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
@@ -314,7 +314,7 @@ public class RadioGroupTests (ITestOutputHelper output)
 
         // Test RadioTitem.HotKey - Should never SetFocus
         //    Selected (0) == Cursor (0) 
-        Assert.True (Application.OnKeyDown (Key.A));
+        Assert.True (Application.NewKeyDown (Key.A));
         Assert.False (rg.HasFocus);
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.Cursor);
@@ -325,14 +325,14 @@ public class RadioGroupTests (ITestOutputHelper output)
         rg.SetFocus ();
 
         //     Make Selected != Cursor
-        Assert.True (Application.OnKeyDown (Key.CursorDown));
+        Assert.True (Application.NewKeyDown (Key.CursorDown));
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
 
         otherView.SetFocus ();
 
         //    Selected != Cursor
-        Assert.True (Application.OnKeyDown (Key.A));
+        Assert.True (Application.NewKeyDown (Key.A));
         Assert.False (rg.HasFocus);
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
@@ -341,7 +341,7 @@ public class RadioGroupTests (ITestOutputHelper output)
         Assert.Equal (0, acceptCount);
 
         //    Selected != Cursor - Should not set focus
-        Assert.True (Application.OnKeyDown (Key.B));
+        Assert.True (Application.NewKeyDown (Key.B));
         Assert.False (rg.HasFocus);
         Assert.Equal (1, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
@@ -349,7 +349,7 @@ public class RadioGroupTests (ITestOutputHelper output)
         Assert.Equal (1, selectCount);
         Assert.Equal (0, acceptCount);
 
-        Assert.True (Application.OnKeyDown (Key.B));
+        Assert.True (Application.NewKeyDown (Key.B));
         Assert.False (rg.HasFocus);
         Assert.Equal (1, rg.SelectedItem);
         Assert.Equal (1, rg.Cursor);
@@ -372,22 +372,22 @@ public class RadioGroupTests (ITestOutputHelper output)
         Assert.NotEmpty (rg.KeyBindings.GetCommands (KeyCode.L | KeyCode.ShiftMask));
         Assert.NotEmpty (rg.KeyBindings.GetCommands (KeyCode.L | KeyCode.AltMask));
 
-        Assert.True (Application.OnKeyDown (Key.T));
+        Assert.True (Application.NewKeyDown (Key.T));
         Assert.Equal (2, rg.SelectedItem);
-        Assert.True (Application.OnKeyDown (Key.L));
+        Assert.True (Application.NewKeyDown (Key.L));
         Assert.Equal (0, rg.SelectedItem);
-        Assert.True (Application.OnKeyDown (Key.J));
+        Assert.True (Application.NewKeyDown (Key.J));
         Assert.Equal (3, rg.SelectedItem);
-        Assert.True (Application.OnKeyDown (Key.R));
+        Assert.True (Application.NewKeyDown (Key.R));
         Assert.Equal (1, rg.SelectedItem);
 
-        Assert.True (Application.OnKeyDown (Key.T.WithAlt));
+        Assert.True (Application.NewKeyDown (Key.T.WithAlt));
         Assert.Equal (2, rg.SelectedItem);
-        Assert.True (Application.OnKeyDown (Key.L.WithAlt));
+        Assert.True (Application.NewKeyDown (Key.L.WithAlt));
         Assert.Equal (0, rg.SelectedItem);
-        Assert.True (Application.OnKeyDown (Key.J.WithAlt));
+        Assert.True (Application.NewKeyDown (Key.J.WithAlt));
         Assert.Equal (3, rg.SelectedItem);
-        Assert.True (Application.OnKeyDown (Key.R.WithAlt));
+        Assert.True (Application.NewKeyDown (Key.R.WithAlt));
         Assert.Equal (1, rg.SelectedItem);
 
         var superView = new View ();

+ 5 - 5
UnitTests/Views/ShortcutTests.cs

@@ -667,7 +667,7 @@ public class ShortcutTests
         var selected = 0;
         shortcut.Selecting += (s, e) => selected++;
 
-        Application.OnKeyDown (key);
+        Application.RaiseKeyDownEvent (key);
 
         Assert.Equal (expectedAccept, accepted);
         Assert.Equal (expectedSelect, selected);
@@ -719,7 +719,7 @@ public class ShortcutTests
         var selected = 0;
         shortcut.Selecting += (s, e) => selected++;
 
-        Application.OnKeyDown (key);
+        Application.RaiseKeyDownEvent (key);
 
         Assert.Equal (expectedAccept, accepted);
         Assert.Equal (expectedSelect, selected);
@@ -751,7 +751,7 @@ public class ShortcutTests
         var accepted = 0;
         shortcut.Accepting += (s, e) => accepted++;
 
-        Application.OnKeyDown (key);
+        Application.RaiseKeyDownEvent (key);
 
         Assert.Equal (expectedAccept, accepted);
 
@@ -792,7 +792,7 @@ public class ShortcutTests
         var action = 0;
         shortcut.Action += () => action++;
 
-        Application.OnKeyDown (key);
+        Application.RaiseKeyDownEvent (key);
 
         Assert.Equal (expectedAction, action);
 
@@ -831,7 +831,7 @@ public class ShortcutTests
         var action = 0;
         shortcut.Action += () => action++;
 
-        Application.OnKeyDown (key);
+        Application.RaiseKeyDownEvent (key);
 
         Assert.Equal (expectedAction, action);
 

+ 1 - 1
UnitTests/Views/StatusBarTests.cs

@@ -104,7 +104,7 @@ public class StatusBarTests
                                      if (iteration == 0)
                                      {
                                          Assert.Equal ("", msg);
-                                         Application.OnKeyDown (Application.QuitKey);
+                                         Application.RaiseKeyDownEvent (Application.QuitKey);
                                      }
                                      else if (iteration == 1)
                                      {

+ 15 - 15
UnitTests/Views/TabViewTests.cs

@@ -398,7 +398,7 @@ public class TabViewTests (ITestOutputHelper output)
         Assert.Equal (tv.SelectedTab.View, top.Focused.MostFocused);
 
         // Press the cursor up key to focus the selected tab
-        Application.OnKeyDown (Key.CursorUp);
+        Application.RaiseKeyDownEvent (Key.CursorUp);
         Application.Refresh ();
 
         // Is the selected tab focused
@@ -416,7 +416,7 @@ public class TabViewTests (ITestOutputHelper output)
                                  };
 
         // Press the cursor right key to select the next tab
-        Application.OnKeyDown (Key.CursorRight);
+        Application.RaiseKeyDownEvent (Key.CursorRight);
         Application.Refresh ();
         Assert.Equal (tab1, oldChanged);
         Assert.Equal (tab2, newChanged);
@@ -425,7 +425,7 @@ public class TabViewTests (ITestOutputHelper output)
         Assert.Equal (tv.MostFocused, top.Focused.MostFocused);
 
         // Press the cursor down key. Since the selected tab has no focusable views, the focus should move to the next view in the toplevel
-        Application.OnKeyDown (Key.CursorDown);
+        Application.RaiseKeyDownEvent (Key.CursorDown);
         Assert.Equal (tab2, tv.SelectedTab);
         Assert.Equal (btn, top.MostFocused);
 
@@ -439,31 +439,31 @@ public class TabViewTests (ITestOutputHelper output)
         tv.SelectedTab.View.Add (btnSubView);
 
         // Press cursor up. Should focus the subview in the selected tab.
-        Application.OnKeyDown (Key.CursorUp);
+        Application.RaiseKeyDownEvent (Key.CursorUp);
         Assert.Equal (tab2, tv.SelectedTab);
         Assert.Equal (btnSubView, top.MostFocused);
 
-        Application.OnKeyDown (Key.CursorUp);
+        Application.RaiseKeyDownEvent (Key.CursorUp);
         Assert.Equal (tab2, top.MostFocused);
 
         // Press the cursor down key twice.
-        Application.OnKeyDown (Key.CursorDown);
-        Application.OnKeyDown (Key.CursorDown);
+        Application.RaiseKeyDownEvent (Key.CursorDown);
+        Application.RaiseKeyDownEvent (Key.CursorDown);
         Assert.Equal (btn, top.MostFocused);
 
         // Press the cursor down key again will focus next view in the toplevel, whic is the TabView
-        Application.OnKeyDown (Key.CursorDown);
+        Application.RaiseKeyDownEvent (Key.CursorDown);
         Assert.Equal (tab2, tv.SelectedTab);
         Assert.Equal (tv, top.Focused);
         Assert.Equal (tab1, tv.MostFocused);
 
         // Press the cursor down key to focus the selected tab view hosting again
-        Application.OnKeyDown (Key.CursorDown);
+        Application.RaiseKeyDownEvent (Key.CursorDown);
         Assert.Equal (tab2, tv.SelectedTab);
         Assert.Equal (btnSubView, top.MostFocused);
 
         // Press the cursor up key to focus the selected tab
-        Application.OnKeyDown (Key.CursorUp);
+        Application.RaiseKeyDownEvent (Key.CursorUp);
         Application.Refresh ();
 
         // Is the selected tab focused
@@ -472,7 +472,7 @@ public class TabViewTests (ITestOutputHelper output)
         Assert.Equal (tv.MostFocused, top.Focused.MostFocused);
 
         // Press the cursor left key to select the previous tab
-        Application.OnKeyDown (Key.CursorLeft);
+        Application.RaiseKeyDownEvent (Key.CursorLeft);
         Application.Refresh ();
         Assert.Equal (tab2, oldChanged);
         Assert.Equal (tab1, newChanged);
@@ -481,7 +481,7 @@ public class TabViewTests (ITestOutputHelper output)
         Assert.Equal (tv.MostFocused, top.Focused.MostFocused);
 
         // Press the end key to select the last tab
-        Application.OnKeyDown (Key.End);
+        Application.RaiseKeyDownEvent (Key.End);
         Application.Refresh ();
         Assert.Equal (tab1, oldChanged);
         Assert.Equal (tab2, newChanged);
@@ -490,7 +490,7 @@ public class TabViewTests (ITestOutputHelper output)
         Assert.Equal (tv.MostFocused, top.Focused.MostFocused);
 
         // Press the home key to select the first tab
-        Application.OnKeyDown (Key.Home);
+        Application.RaiseKeyDownEvent (Key.Home);
         Application.Refresh ();
         Assert.Equal (tab2, oldChanged);
         Assert.Equal (tab1, newChanged);
@@ -499,7 +499,7 @@ public class TabViewTests (ITestOutputHelper output)
         Assert.Equal (tv.MostFocused, top.Focused.MostFocused);
 
         // Press the page down key to select the next set of tabs
-        Application.OnKeyDown (Key.PageDown);
+        Application.RaiseKeyDownEvent (Key.PageDown);
         Application.Refresh ();
         Assert.Equal (tab1, oldChanged);
         Assert.Equal (tab2, newChanged);
@@ -508,7 +508,7 @@ public class TabViewTests (ITestOutputHelper output)
         Assert.Equal (tv.MostFocused, top.Focused.MostFocused);
 
         // Press the page up key to select the previous set of tabs
-        Application.OnKeyDown (Key.PageUp);
+        Application.RaiseKeyDownEvent (Key.PageUp);
         Application.Refresh ();
         Assert.Equal (tab2, oldChanged);
         Assert.Equal (tab1, newChanged);

+ 11 - 11
UnitTests/Views/TableViewTests.cs

@@ -3215,12 +3215,12 @@ A B C
         tableView.SelectedColumn = 1;
 
         // Pressing left should move us to the first column without changing focus
-        Application.OnKeyDown (Key.CursorLeft);
+        Application.RaiseKeyDownEvent (Key.CursorLeft);
         Assert.Same (tableView, Application.Top!.MostFocused);
         Assert.True (tableView.HasFocus);
 
         // Because we are now on the leftmost cell a further left press should move focus
-        Application.OnKeyDown (Key.CursorLeft);
+        Application.RaiseKeyDownEvent (Key.CursorLeft);
 
         Assert.NotSame (tableView, Application.Top.MostFocused);
         Assert.False (tableView.HasFocus);
@@ -3240,12 +3240,12 @@ A B C
         tableView.SelectedRow = 1;
 
         // First press should move us up
-        Application.OnKeyDown (Key.CursorUp);
+        Application.RaiseKeyDownEvent (Key.CursorUp);
         Assert.Same (tableView, Application.Top!.MostFocused);
         Assert.True (tableView.HasFocus);
 
         // Because we are now on the top row a further press should move focus
-        Application.OnKeyDown (Key.CursorUp);
+        Application.RaiseKeyDownEvent (Key.CursorUp);
 
         Assert.NotSame (tableView, Application.Top.MostFocused);
         Assert.False (tableView.HasFocus);
@@ -3264,12 +3264,12 @@ A B C
         tableView.SelectedColumn = tableView.Table.Columns - 2;
 
         // First press should move us to the rightmost column without changing focus
-        Application.OnKeyDown (Key.CursorRight);
+        Application.RaiseKeyDownEvent (Key.CursorRight);
         Assert.Same (tableView, Application.Top!.MostFocused);
         Assert.True (tableView.HasFocus);
 
         // Because we are now on the rightmost cell, a further right press should move focus
-        Application.OnKeyDown (Key.CursorRight);
+        Application.RaiseKeyDownEvent (Key.CursorRight);
 
         Assert.NotSame (tableView, Application.Top.MostFocused);
         Assert.False (tableView.HasFocus);
@@ -3289,12 +3289,12 @@ A B C
         tableView.SelectedRow = tableView.Table.Rows - 2;
 
         // First press should move us to the bottommost row without changing focus
-        Application.OnKeyDown (Key.CursorDown);
+        Application.RaiseKeyDownEvent (Key.CursorDown);
         Assert.Same (tableView, Application.Top!.MostFocused);
         Assert.True (tableView.HasFocus);
 
         // Because we are now on the bottommost cell, a further down press should move focus
-        Application.OnKeyDown (Key.CursorDown);
+        Application.RaiseKeyDownEvent (Key.CursorDown);
 
         Assert.NotSame (tableView, Application.Top.MostFocused);
         Assert.False (tableView.HasFocus);
@@ -3315,7 +3315,7 @@ A B C
         tableView.SelectedColumn = 1;
 
         // Pressing shift-left should give us a multi selection
-        Application.OnKeyDown (Key.CursorLeft.WithShift);
+        Application.RaiseKeyDownEvent (Key.CursorLeft.WithShift);
         Assert.Same (tableView, Application.Top!.MostFocused);
         Assert.True (tableView.HasFocus);
         Assert.Equal (2, tableView.GetAllSelectedCells ().Count ());
@@ -3323,7 +3323,7 @@ A B C
         // Because we are now on the leftmost cell a further left press would normally move focus
         // However there is an ongoing selection so instead the operation clears the selection and
         // gets swallowed (not resulting in a focus change)
-        Application.OnKeyDown (Key.CursorLeft);
+        Application.RaiseKeyDownEvent (Key.CursorLeft);
 
         // Selection 'clears' just to the single cell and we remain focused
         Assert.Single (tableView.GetAllSelectedCells ());
@@ -3331,7 +3331,7 @@ A B C
         Assert.True (tableView.HasFocus);
 
         // A further left will switch focus
-        Application.OnKeyDown (Key.CursorLeft);
+        Application.RaiseKeyDownEvent (Key.CursorLeft);
 
         Assert.NotSame (tableView, Application.Top.MostFocused);
         Assert.False (tableView.HasFocus);

+ 3 - 3
UnitTests/Views/TextFieldTests.cs

@@ -524,7 +524,7 @@ public class TextFieldTests (ITestOutputHelper output)
         Application.Top = new ();
         Application.Top.Add (tf);
         tf.SetFocus ();
-        Application.OnKeyDown (Key.Space);
+        Application.NewKeyDown (Key.Space);
 
         Application.Top.Dispose ();
         Application.ResetState (true);
@@ -541,7 +541,7 @@ public class TextFieldTests (ITestOutputHelper output)
         Application.Top = new ();
         Application.Top.Add (tf);
         tf.SetFocus ();
-        Application.OnKeyDown (Key.Enter);
+        Application.NewKeyDown (Key.Enter);
 
         Assert.Equal (0, selectingCount);
 
@@ -560,7 +560,7 @@ public class TextFieldTests (ITestOutputHelper output)
         Application.Top = new ();
         Application.Top.Add (tf);
         tf.SetFocus ();
-        Application.OnKeyDown (Key.Enter);
+        Application.NewKeyDown (Key.Enter);
 
         Assert.Equal (1, acceptedCount);
 

+ 20 - 20
UnitTests/Views/ToplevelTests.cs

@@ -299,26 +299,26 @@ public partial class ToplevelTests (ITestOutputHelper output)
         Assert.Equal (tf1W1, top.MostFocused);
 
         Assert.True (isRunning);
-        Assert.True (Application.OnKeyDown (Application.QuitKey));
+        Assert.True (Application.RaiseKeyDownEvent (Application.QuitKey));
         Assert.False (isRunning);
-        Assert.True (Application.OnKeyDown (Key.Z.WithCtrl));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Z.WithCtrl));
 
-        Assert.True (Application.OnKeyDown (Key.F5)); // refresh
+        Assert.True (Application.RaiseKeyDownEvent (Key.F5)); // refresh
 
-        Assert.True (Application.OnKeyDown (Key.Tab));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Tab));
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tvW1, top.MostFocused);
-        Assert.True (Application.OnKeyDown (Key.Tab));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Tab));
         Assert.Equal ($"\tFirst line Win1{Environment.NewLine}Second line Win1", tvW1.Text);
-        Assert.True (Application.OnKeyDown (Key.Tab.WithShift));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Tab.WithShift));
         Assert.Equal ($"First line Win1{Environment.NewLine}Second line Win1", tvW1.Text);
 
         var prevMostFocusedSubview = top.MostFocused;
 
-        Assert.True (Application.OnKeyDown (Key.F6)); // move to next TabGroup (win2)
+        Assert.True (Application.RaiseKeyDownEvent (Key.F6)); // move to next TabGroup (win2)
         Assert.Equal (win2, top.Focused);
 
-        Assert.True (Application.OnKeyDown (Key.F6.WithShift)); // move to prev TabGroup (win1)
+        Assert.True (Application.RaiseKeyDownEvent (Key.F6.WithShift)); // move to prev TabGroup (win1)
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tf2W1, top.MostFocused);  // BUGBUG: Should be prevMostFocusedSubview - We need to cache the last focused view in the TabGroup somehow
 
@@ -327,13 +327,13 @@ public partial class ToplevelTests (ITestOutputHelper output)
         Assert.Equal (tvW1, top.MostFocused);
 
         tf2W1.SetFocus ();
-        Assert.True (Application.OnKeyDown (Key.Tab)); // tf2W1 is last subview in win1 - tabbing should take us to first subview of win1
+        Assert.True (Application.RaiseKeyDownEvent (Key.Tab)); // tf2W1 is last subview in win1 - tabbing should take us to first subview of win1
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tf1W1, top.MostFocused);
-        Assert.True (Application.OnKeyDown (Key.CursorRight)); // move char to right in tf1W1. We're at last char so nav to next view
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorRight)); // move char to right in tf1W1. We're at last char so nav to next view
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tvW1, top.MostFocused);
-        Assert.True (Application.OnKeyDown (Key.CursorDown)); // move down to next view (tvW1)
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorDown)); // move down to next view (tvW1)
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tvW1, top.MostFocused);
 #if UNIX_KEY_BINDINGS
@@ -341,34 +341,34 @@ public partial class ToplevelTests (ITestOutputHelper output)
         Assert.Equal (win1, top.GetFocused ());
         Assert.Equal (tf2W1, top.MostFocused);
 #endif
-        Assert.True (Application.OnKeyDown (Key.Tab.WithShift)); // Ignored. TextView eats shift-tab by default
+        Assert.True (Application.RaiseKeyDownEvent (Key.Tab.WithShift)); // Ignored. TextView eats shift-tab by default
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tvW1, top.MostFocused);
         tvW1.AllowsTab = false;
-        Assert.True (Application.OnKeyDown (Key.Tab.WithShift));
+        Assert.True (Application.RaiseKeyDownEvent (Key.Tab.WithShift));
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tf1W1, top.MostFocused);
-        Assert.True (Application.OnKeyDown (Key.CursorLeft));
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorLeft));
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tf2W1, top.MostFocused);
-        Assert.True (Application.OnKeyDown (Key.CursorUp));
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorUp));
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tvW1, top.MostFocused);
 
         // nav to win2
-        Assert.True (Application.OnKeyDown (Key.F6));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F6));
         Assert.Equal (win2, top.Focused);
         Assert.Equal (tf1W2, top.MostFocused);
-        Assert.True (Application.OnKeyDown (Key.F6.WithShift));
+        Assert.True (Application.RaiseKeyDownEvent (Key.F6.WithShift));
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tf2W1, top.MostFocused);
-        Assert.True (Application.OnKeyDown (Application.NextTabGroupKey));
+        Assert.True (Application.RaiseKeyDownEvent (Application.NextTabGroupKey));
         Assert.Equal (win2, top.Focused);
         Assert.Equal (tf1W2, top.MostFocused);
-        Assert.True (Application.OnKeyDown (Application.PrevTabGroupKey));
+        Assert.True (Application.RaiseKeyDownEvent (Application.PrevTabGroupKey));
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tf2W1, top.MostFocused);
-        Assert.True (Application.OnKeyDown (Key.CursorUp));
+        Assert.True (Application.RaiseKeyDownEvent (Key.CursorUp));
         Assert.Equal (win1, top.Focused);
         Assert.Equal (tvW1, top.MostFocused);
 

+ 1 - 1
UnitTests/Views/TreeTableSourceTests.cs

@@ -187,7 +187,7 @@ public class TreeTableSourceTests : IDisposable
         Assert.Equal (0, tv.SelectedRow);
         Assert.Equal (1, tv.SelectedColumn);
 
-        Application.OnKeyDown (Key.CursorRight);
+        Application.RaiseKeyDownEvent (Key.CursorRight);
 
         tv.Draw ();