This commit is contained in:
Tig
2024-07-27 09:29:50 -04:00
parent 5e28ba1ef9
commit ee3c48ae50
6 changed files with 53 additions and 27 deletions

View File

@@ -301,7 +301,6 @@ public static partial class Application // Keyboard handling
Command.NextView,
() =>
{
// TODO: Move this method to Application.Navigation.cs
ApplicationNavigation.MoveNextView ();
return true;
@@ -312,7 +311,6 @@ public static partial class Application // Keyboard handling
Command.PreviousView,
() =>
{
// TODO: Move this method to Application.Navigation.cs
ApplicationNavigation.MovePreviousView ();
return true;
@@ -323,7 +321,6 @@ public static partial class Application // Keyboard handling
Command.NextViewOrTop,
() =>
{
// TODO: Move this method to Application.Navigation.cs
ApplicationNavigation.MoveNextViewOrTop ();
return true;
@@ -334,7 +331,6 @@ public static partial class Application // Keyboard handling
Command.PreviousViewOrTop,
() =>
{
// TODO: Move this method to Application.Navigation.cs
ApplicationNavigation.MovePreviousViewOrTop ();
return true;

View File

@@ -67,9 +67,9 @@ internal static class ApplicationNavigation
{
Toplevel? top = Application.Current!.Modal ? Application.Current : Application.Top;
if (!Application.Current.AdvanceFocus (NavigationDirection.Forward))
if (!Application.Current.AdvanceFocus (NavigationDirection.Forward, true))
{
Application.Current.AdvanceFocus (NavigationDirection.Forward);
Application.Current.AdvanceFocus (NavigationDirection.Forward, true);
}
if (top != Application.Current.Focused && top != Application.Current.Focused?.Focused)
@@ -129,11 +129,11 @@ internal static class ApplicationNavigation
if (ApplicationOverlapped.OverlappedTop is null)
{
Toplevel? top = Application.Current!.Modal ? Application.Current : Application.Top;
top!.AdvanceFocus (NavigationDirection.Backward);
top!.AdvanceFocus (NavigationDirection.Backward, true);
if (top.Focused is null)
{
top.AdvanceFocus (NavigationDirection.Backward);
top.AdvanceFocus (NavigationDirection.Backward, true);
}
top.SetNeedsDisplay ();

View File

@@ -523,11 +523,12 @@ public partial class View // Focus and cross-view navigation management (TabStop
/// </para>
/// </remarks>
/// <param name="direction"></param>
/// <param name="acrossGroupOrOverlapped">If <see langword="true"/> will advance into ...</param>
/// <returns>
/// <see langword="true"/> if focus was changed to another subview (or stayed on this one), <see langword="false"/>
/// otherwise.
/// </returns>
public bool AdvanceFocus (NavigationDirection direction)
public bool AdvanceFocus (NavigationDirection direction, bool acrossGroupOrOverlapped = false)
{
if (!CanBeVisible (this))
{
@@ -569,14 +570,30 @@ public partial class View // Focus and cross-view navigation management (TabStop
if (w.HasFocus)
{
// A subview has focus, tell *it* to FocusNext
if (w.AdvanceFocus (direction))
if (w.AdvanceFocus (direction, acrossGroupOrOverlapped))
{
// The subview changed which of it's subviews had focus
return true;
}
else
{
if (acrossGroupOrOverlapped && Arrangement.HasFlag (ViewArrangement.Overlapped))
{
return false;
}
}
Debug.Assert (w.HasFocus);
if (w.Focused is null)
{
// No next focusable view was found.
if (w.Arrangement.HasFlag (ViewArrangement.Overlapped))
{
// Keep focus w/in w
return false;
}
}
// The subview has no subviews that can be next. Cache that we found a focused subview.
focusedFound = true;
@@ -589,17 +606,17 @@ public partial class View // Focus and cross-view navigation management (TabStop
// Make Focused Leave
Focused.SetHasFocus (false, w);
//// If the focused view is overlapped don't focus on the next if it's not overlapped.
//if (Focused.Arrangement.HasFlag (ViewArrangement.Overlapped)/* && !w.Arrangement.HasFlag (ViewArrangement.Overlapped)*/)
// If the focused view is overlapped don't focus on the next if it's not overlapped.
//if (acrossGroupOrOverlapped && Focused.Arrangement.HasFlag (ViewArrangement.Overlapped)/* && !w.Arrangement.HasFlag (ViewArrangement.Overlapped)*/)
//{
// return false;
//}
//// If the focused view is not overlapped and the next is, skip it
//if (!Focused.Arrangement.HasFlag (ViewArrangement.Overlapped) && w.Arrangement.HasFlag (ViewArrangement.Overlapped))
//{
// continue;
//}
// If the focused view is not overlapped and the next is, skip it
if (!acrossGroupOrOverlapped && !Focused.Arrangement.HasFlag (ViewArrangement.Overlapped) && w.Arrangement.HasFlag (ViewArrangement.Overlapped))
{
continue;
}
switch (direction)
{
@@ -766,7 +783,8 @@ public partial class View // Focus and cross-view navigation management (TabStop
{
return;
}
// BUGBUG: TabStop and CanFocus should be decoupled.
_tabStop = CanFocus && value;
}
}

View File

@@ -67,5 +67,5 @@ public enum ViewArrangement
/// Use Ctrl-Tab (Ctrl-PageDown) / Ctrl-Shift-Tab (Ctrl-PageUp) to move between overlapped views.
/// </para>
/// </remarks>
Overlapped = 32
Overlapped = 32,
}

View File

@@ -90,6 +90,9 @@ public class AdornmentEditor : View
BorderStyle = LineStyle.Dashed;
Initialized += AdornmentEditor_Initialized;
//Arrangement = ViewArrangement.Group;
}
private void AdornmentEditor_Initialized (object sender, EventArgs e)

View File

@@ -18,6 +18,7 @@ public class ViewExperiments : Scenario
Title = GetQuitKeyAndName ()
};
var view = new View
{
X = 2,
@@ -81,6 +82,22 @@ public class ViewExperiments : Scenario
view2.Add (button);
var editor = new AdornmentsEditor
{
X = 0,
Y = 0,
AutoSelectViewToEdit = true
};
app.Add (editor);
button = new ()
{
Y = 0,
X = Pos.X (view),
Title = "Button_0",
};
app.Add (button);
button = new ()
{
X = Pos.AnchorEnd (),
@@ -88,14 +105,6 @@ public class ViewExperiments : Scenario
Title = "Button_5",
};
var editor = new AdornmentsEditor
{
X = 0,
Y = 0,
AutoSelectViewToEdit = true
};
app.Add (editor);
view.X = 34;
view.Y = 4;
app.Add (view);