瀏覽代碼

AdvanceFocus works correctly for most cases

Tig 1 年之前
父節點
當前提交
7f3b0eb55b
共有 2 個文件被更改,包括 18 次插入19 次删除
  1. 16 17
      Terminal.Gui/View/View.Navigation.cs
  2. 2 2
      UICatalog/Scenarios/ViewExperiments.cs

+ 16 - 17
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 
-
-                //// 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;
+            }
 
-                //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);
+                }
             }
         }
 

+ 2 - 2
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);