Code cleanup

This commit is contained in:
Tig
2024-08-27 20:54:25 -07:00
parent 8bdb0f64d7
commit a469d39b57
2 changed files with 31 additions and 41 deletions

View File

@@ -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);
}

View File

@@ -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);
}
}