فهرست منبع

Ensure tab get focus if the container can't get focus.

BDisp 8 ماه پیش
والد
کامیت
8c910fa04d
1فایلهای تغییر یافته به همراه7 افزوده شده و 2 حذف شده
  1. 7 2
      Terminal.Gui/Views/TabView/TabView.cs

+ 7 - 2
Terminal.Gui/Views/TabView/TabView.cs

@@ -142,7 +142,7 @@ public class TabView : View
 
 
             if (old != _selectedTab)
             if (old != _selectedTab)
             {
             {
-                if (_selectedTabHasFocus || !_containerView.CanFocus)
+                if (TabCanSetFocus ())
                 {
                 {
                     SelectedTab?.SetFocus ();
                     SelectedTab?.SetFocus ();
                 }
                 }
@@ -153,6 +153,11 @@ public class TabView : View
         }
         }
     }
     }
 
 
+    private bool TabCanSetFocus ()
+    {
+        return IsInitialized && SelectedTab is { } && (_selectedTabHasFocus || !_containerView.CanFocus);
+    }
+
     private void ContainerViewCanFocus (object sender, EventArgs eventArgs)
     private void ContainerViewCanFocus (object sender, EventArgs eventArgs)
     {
     {
         _containerView.CanFocus = _containerView.Subviews.Count (v => v.CanFocus) > 0;
         _containerView.CanFocus = _containerView.Subviews.Count (v => v.CanFocus) > 0;
@@ -509,7 +514,7 @@ public class TabView : View
             i += tabTextWidth + 1;
             i += tabTextWidth + 1;
         }
         }
 
 
-        if (_selectedTabHasFocus)
+        if (TabCanSetFocus ())
         {
         {
             SelectedTab?.SetFocus ();
             SelectedTab?.SetFocus ();
         }
         }