Tig 11 kuukautta sitten
vanhempi
commit
a469d39b57

+ 5 - 12
Terminal.Gui/Application/Application.Keyboard.cs

@@ -298,21 +298,14 @@ public static partial class Application // Keyboard handling
                     static () =>
                     {
                         // TODO: This OverlapppedTop tomfoolery goes away in addressing #2491
-                        if (ApplicationOverlapped.OverlappedTop is null)
+                        if (ApplicationOverlapped.OverlappedTop is null && Current is { })
                         {
-                            if ((View?)Current is { })
-                            {
-                                return Current.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabGroup);
-                            }
+                            return Current.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabGroup);
                         }
-                        else
-                        {
-                            ApplicationOverlapped.OverlappedMoveNext ();
 
-                            return true;
-                        }
+                        ApplicationOverlapped.OverlappedMoveNext ();
 
-                        return false;
+                        return true;
                     }
                    );
 
@@ -323,7 +316,7 @@ public static partial class Application // Keyboard handling
                         // TODO: This OverlapppedTop tomfoolery goes away in addressing #2491
                         if (ApplicationOverlapped.OverlappedTop is null)
                         {
-                            if ((View?)Current is { })
+                            if (Current is { })
                             {
                                 return Current.AdvanceFocus (NavigationDirection.Backward, TabBehavior.TabGroup);
                             }

+ 25 - 28
Terminal.Gui/Application/ApplicationNavigation.cs

@@ -7,7 +7,6 @@ namespace Terminal.Gui;
 /// </summary>
 public class ApplicationNavigation
 {
-
     /// <summary>
     ///     Initializes a new instance of the <see cref="ApplicationNavigation"/> class.
     /// </summary>
@@ -16,38 +15,17 @@ public class ApplicationNavigation
         // TODO: Move navigation key bindings here from AddApplicationKeyBindings
     }
 
-    private View? _focused = null;
-
-    /// <summary>
-    ///     Gets the most focused <see cref="View"/> in the application, if there is one.
-    /// </summary>
-    public View? GetFocused () { return _focused; }
-
-    /// <summary>
-    ///     INTERNAL method to record the most focused <see cref="View"/> in the application.
-    /// </summary>
-    /// <remarks>
-    ///     Raises <see cref="FocusedChanged"/>.
-    /// </remarks>
-    internal void SetFocused (View? value)
-    {
-        if (_focused == value)
-        {
-            return;
-        }
-
-        _focused = value;
-
-        FocusedChanged?.Invoke (null, EventArgs.Empty);
-
-        return;
-    }
+    private View? _focused;
 
     /// <summary>
     ///     Raised when the most focused <see cref="View"/> in the application has changed.
     /// </summary>
     public event EventHandler<EventArgs>? FocusedChanged;
 
+    /// <summary>
+    ///     Gets the most focused <see cref="View"/> in the application, if there is one.
+    /// </summary>
+    public View? GetFocused () { return _focused; }
 
     /// <summary>
     ///     Gets whether <paramref name="view"/> is in the Subview hierarchy of <paramref name="start"/>.
@@ -74,7 +52,8 @@ public class ApplicationNavigation
                 return true;
             }
 
-            var found = IsInHierarchy (subView, view);
+            bool found = IsInHierarchy (subView, view);
+
             if (found)
             {
                 return found;
@@ -83,4 +62,22 @@ public class ApplicationNavigation
 
         return false;
     }
+
+    /// <summary>
+    ///     INTERNAL method to record the most focused <see cref="View"/> in the application.
+    /// </summary>
+    /// <remarks>
+    ///     Raises <see cref="FocusedChanged"/>.
+    /// </remarks>
+    internal void SetFocused (View? value)
+    {
+        if (_focused == value)
+        {
+            return;
+        }
+
+        _focused = value;
+
+        FocusedChanged?.Invoke (null, EventArgs.Empty);
+    }
 }