diff --git a/Terminal.Gui/Application/Application.Keyboard.cs b/Terminal.Gui/Application/Application.Keyboard.cs
index acbfce7d0..4b8888b7b 100644
--- a/Terminal.Gui/Application/Application.Keyboard.cs
+++ b/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);
- }
- }
- else
- {
- ApplicationOverlapped.OverlappedMoveNext ();
-
- return true;
+ return Current.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabGroup);
}
- return false;
+ ApplicationOverlapped.OverlappedMoveNext ();
+
+ 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);
}
diff --git a/Terminal.Gui/Application/ApplicationNavigation.cs b/Terminal.Gui/Application/ApplicationNavigation.cs
index 0a29d0711..f30f17520 100644
--- a/Terminal.Gui/Application/ApplicationNavigation.cs
+++ b/Terminal.Gui/Application/ApplicationNavigation.cs
@@ -7,7 +7,6 @@ namespace Terminal.Gui;
///
public class ApplicationNavigation
{
-
///
/// Initializes a new instance of the class.
///
@@ -16,38 +15,17 @@ public class ApplicationNavigation
// TODO: Move navigation key bindings here from AddApplicationKeyBindings
}
- private View? _focused = null;
-
- ///
- /// Gets the most focused in the application, if there is one.
- ///
- public View? GetFocused () { return _focused; }
-
- ///
- /// INTERNAL method to record the most focused in the application.
- ///
- ///
- /// Raises .
- ///
- internal void SetFocused (View? value)
- {
- if (_focused == value)
- {
- return;
- }
-
- _focused = value;
-
- FocusedChanged?.Invoke (null, EventArgs.Empty);
-
- return;
- }
+ private View? _focused;
///
/// Raised when the most focused in the application has changed.
///
public event EventHandler? FocusedChanged;
+ ///
+ /// Gets the most focused in the application, if there is one.
+ ///
+ public View? GetFocused () { return _focused; }
///
/// Gets whether is in the Subview hierarchy of .
@@ -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;
}
+
+ ///
+ /// INTERNAL method to record the most focused in the application.
+ ///
+ ///
+ /// Raises .
+ ///
+ internal void SetFocused (View? value)
+ {
+ if (_focused == value)
+ {
+ return;
+ }
+
+ _focused = value;
+
+ FocusedChanged?.Invoke (null, EventArgs.Empty);
+ }
}