diff --git a/Terminal.Gui/View/View.Navigation.cs b/Terminal.Gui/View/View.Navigation.cs index c282cebf9..5936dec9e 100644 --- a/Terminal.Gui/View/View.Navigation.cs +++ b/Terminal.Gui/View/View.Navigation.cs @@ -429,28 +429,27 @@ public partial class View // Focus and cross-view navigation management (TabStop // We're moving beyond the last subview // Determine if focus should remain in this focus chain, or move to the superview's focus chain - if (SuperView is { } && SuperView.TabStop != TabBehavior.NoStop && SuperView.GetScopedTabIndexes (direction, behavior).Length > 1) + // - If we are TabStop and our SuperView is TabStop move to superview's focus chain + if (TabStop == TabBehavior.TabStop && SuperView is { TabStop: TabBehavior.TabStop }) { - //if (behavior == TabBehavior.TabGroup && behavior == TabStop && SuperView?.TabStop == TabBehavior.TabGroup) - { - // Our superview has an focusable subview in addition to us - return false; - } + return false; } - // If our superview - //if (behavior == TabBehavior.TabGroup && behavior == TabStop && SuperView?.TabStop == TabBehavior.TabGroup) + // - If we are TabStop and our SuperView has at least one other TabStop subview, move to the SuperView's chain + if (TabStop == TabBehavior.TabStop && SuperView is { } && SuperView.GetScopedTabIndexes (direction, behavior).Length > 1) { - next = 0; - //return + return false; + } - //// Go down the subview-hierarchy and leave - //// BUGBUG: This doesn't seem right - //Focused.HasFocus = false; - - //// TODO: Should we check the return value of SetHasFocus? - - //return false; + // - If we are TabGrup and our SuperView has at least one other TabGroup subview, move to the SuperView's chain + if (TabStop == TabBehavior.TabGroup && SuperView is { TabStop: TabBehavior.TabGroup }) + { + if (behavior == TabBehavior.TabGroup) + { + // Wrap to first focusable views + // BUGBUG: This should do a Restore Focus instead + index = GetScopedTabIndexes (direction, null); + } } } diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs index 637475a6a..404ca8dc1 100644 --- a/UICatalog/Scenarios/ViewExperiments.cs +++ b/UICatalog/Scenarios/ViewExperiments.cs @@ -53,11 +53,11 @@ public class ViewExperiments : Scenario testFrame.Add (tiledView1); testFrame.Add (tiledView2); - var overlappedView1 = CreateOverlappedView (2, Pos.Center(), Pos.Center()); + var overlappedView1 = CreateOverlappedView (2, Pos.Center()-5, Pos.Center()); var tiledSubView = CreateTiledView (4, 0, 2); overlappedView1.Add (tiledSubView); - var overlappedView2 = CreateOverlappedView (3, Pos.Center() + 5, Pos.Center() + 5); + var overlappedView2 = CreateOverlappedView (3, Pos.Center() + 10, Pos.Center() + 5); tiledSubView = CreateTiledView (4, 0, 2); overlappedView2.Add (tiledSubView);