Просмотр исходного кода

More Toplevel.cs organization & docs

Tig 1 год назад
Родитель
Сommit
fe5cbe4df3

+ 7 - 2
Terminal.Gui/Application/Application.Keyboard.cs

@@ -230,9 +230,14 @@ public static partial class Application // Keyboard handling
     ///     This is an internal method used by the <see cref="View"/> class to add Application key bindings.
     ///     This is an internal method used by the <see cref="View"/> class to add Application key bindings.
     /// </remarks>
     /// </remarks>
     /// <param name="key">The key being bound.</param>
     /// <param name="key">The key being bound.</param>
-    /// <param name="view">The view that is bound to the key.</param>
-    internal static void AddKeyBinding (Key key, View view)
+    /// <param name="view">The view that is bound to the key. If <see langword="null"/>, <see cref="Application.Current"/> will be used.</param>
+    internal static void AddKeyBinding (Key key, [CanBeNull] View view)
     {
     {
+        if (view is null)
+        {
+            view = Current;
+        }
+
         if (!_keyBindings.ContainsKey (key))
         if (!_keyBindings.ContainsKey (key))
         {
         {
             _keyBindings [key] = [];
             _keyBindings [key] = [];

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

@@ -577,6 +577,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
             Iteration?.Invoke (null, new ());
             Iteration?.Invoke (null, new ());
             EnsureModalOrVisibleAlwaysOnTop (state.Toplevel);
             EnsureModalOrVisibleAlwaysOnTop (state.Toplevel);
 
 
+            // TODO: Overlapped - Move elsewhere
             if (state.Toplevel != Current)
             if (state.Toplevel != Current)
             {
             {
                 OverlappedTop?.OnDeactivate (state.Toplevel);
                 OverlappedTop?.OnDeactivate (state.Toplevel);

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

@@ -18,7 +18,7 @@ public static partial class Application // Toplevel handling
     ///     <see cref="Toplevel"/> .
     ///     <see cref="Toplevel"/> .
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
-    ///     Only relevant in scenarios where <see cref="Toplevel.IsOverlappedContainer"/> is <see langword="true"/>.
+    ///     This will only be distinct from <see cref="Application.Top"/> in scenarios where <see cref="Toplevel.IsOverlappedContainer"/> is <see langword="true"/>.
     /// </remarks>
     /// </remarks>
     /// <value>The current.</value>
     /// <value>The current.</value>
     public static Toplevel Current { get; private set; }
     public static Toplevel Current { get; private set; }