Bläddra i källkod

Nav mostly works again

Tig 1 år sedan
förälder
incheckning
7dd0c4c656
1 ändrade filer med 32 tillägg och 9 borttagningar
  1. 32 9
      Terminal.Gui/View/View.Navigation.cs

+ 32 - 9
Terminal.Gui/View/View.Navigation.cs

@@ -90,9 +90,12 @@ public partial class View // Focus and cross-view navigation management (TabStop
                 return false;
                 return false;
             }
             }
 
 
-            Focused.RestoreFocus (TabBehavior.TabStop);
+            //Focused.RestoreFocus (TabBehavior.TabStop);
 
 
-            return true;
+            //if (Focused is { })
+            //{
+            //    return true;
+            //}
 
 
             // Wrap around
             // Wrap around
             //if (SuperView is {})
             //if (SuperView is {})
@@ -294,14 +297,31 @@ public partial class View // Focus and cross-view navigation management (TabStop
             return;
             return;
         }
         }
 
 
-        View deepest = FindDeepestFocusableView (behavior, direction);
+        //View deepest = FindDeepestFocusableView (behavior, direction);
 
 
-        if (deepest is { })
+        //if (deepest is { })
+        //{
+        //    deepest.SetFocus ();
+        //}
+
+        //SetFocus ();
+
+        if (_tabIndexes is null)
         {
         {
-            deepest.SetFocus ();
+            SuperView?.SetFocus (this);
+
+            return;
         }
         }
 
 
-        SetFocus ();
+        foreach (View view in _tabIndexes)
+        {
+            if (view.CanFocus && view.TabStop == behavior && view.Visible && view.Enabled)
+            {
+                SetFocus (view);
+
+                return;
+            }
+        }
     }
     }
 
 
     [CanBeNull]
     [CanBeNull]
@@ -560,6 +580,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
         View f = Focused;
         View f = Focused;
         Focused = viewToEnterFocus;
         Focused = viewToEnterFocus;
         Focused?.SetHasFocus (true, f, true);
         Focused?.SetHasFocus (true, f, true);
+        Focused?.FocusDeepest (null, NavigationDirection.Forward);
 
 
         // Recursively set focus down the view hierarchy
         // Recursively set focus down the view hierarchy
         if (SuperView is { })
         if (SuperView is { })
@@ -592,17 +613,19 @@ public partial class View // Focus and cross-view navigation management (TabStop
     {
     {
         if (HasFocus != newHasFocus || force)
         if (HasFocus != newHasFocus || force)
         {
         {
+            _hasFocus = newHasFocus;
+
             if (newHasFocus)
             if (newHasFocus)
             {
             {
                 Debug.Assert (view is null || ApplicationNavigation.IsInHierarchy (SuperView, view));
                 Debug.Assert (view is null || ApplicationNavigation.IsInHierarchy (SuperView, view));
                 OnEnter (view);
                 OnEnter (view);
                 ApplicationNavigation.Focused = this;
                 ApplicationNavigation.Focused = this;
-                _hasFocus = true;
+                //_hasFocus = true;
             }
             }
             else
             else
             {
             {
                 OnLeave (view);
                 OnLeave (view);
-                _hasFocus = false;
+                //_hasFocus = false;
             }
             }
 
 
             SetNeedsDisplay ();
             SetNeedsDisplay ();
@@ -612,7 +635,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
         if (!newHasFocus && Focused is { })
         if (!newHasFocus && Focused is { })
         {
         {
             View f = Focused;
             View f = Focused;
-            //f.OnLeave (view);
+            f.OnLeave (view);
             f.SetHasFocus (false, view, true);
             f.SetHasFocus (false, view, true);
             Focused = null;
             Focused = null;
         }
         }