From 8c910fa04d8ee1bb8a925c068f1a170e48c99aad Mon Sep 17 00:00:00 2001 From: BDisp Date: Wed, 20 Nov 2024 14:30:36 +0000 Subject: [PATCH] Ensure tab get focus if the container can't get focus. --- Terminal.Gui/Views/TabView/TabView.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/Views/TabView/TabView.cs b/Terminal.Gui/Views/TabView/TabView.cs index 966099237..7916911fc 100644 --- a/Terminal.Gui/Views/TabView/TabView.cs +++ b/Terminal.Gui/Views/TabView/TabView.cs @@ -142,7 +142,7 @@ public class TabView : View if (old != _selectedTab) { - if (_selectedTabHasFocus || !_containerView.CanFocus) + if (TabCanSetFocus ()) { 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) { _containerView.CanFocus = _containerView.Subviews.Count (v => v.CanFocus) > 0; @@ -509,7 +514,7 @@ public class TabView : View i += tabTextWidth + 1; } - if (_selectedTabHasFocus) + if (TabCanSetFocus ()) { SelectedTab?.SetFocus (); }