diff --git a/Terminal.Gui/Core/Toplevel.cs b/Terminal.Gui/Core/Toplevel.cs index 16bdcfd4e..ab5334a05 100644 --- a/Terminal.Gui/Core/Toplevel.cs +++ b/Terminal.Gui/Core/Toplevel.cs @@ -182,7 +182,7 @@ namespace Terminal.Gui { case Key.CursorRight: case Key.CursorDown: case Key.ControlI: // Unix - var old = Focused; + var old = GetDeepestFocusedSubview (Focused); if (!FocusNext ()) FocusNext (); if (old != Focused) { @@ -195,7 +195,7 @@ namespace Terminal.Gui { case Key.CursorLeft: case Key.CursorUp: case Key.BackTab: - old = Focused; + old = GetDeepestFocusedSubview (Focused); if (!FocusPrev ()) FocusPrev (); if (old != Focused) { @@ -213,6 +213,16 @@ namespace Terminal.Gui { return false; } + View GetDeepestFocusedSubview (View view) + { + foreach (var v in view.Subviews) { + if (v.HasFocus) { + return GetDeepestFocusedSubview (v); + } + } + return view; + } + IEnumerable GetToplevelSubviews (bool isForward) { if (SuperView == null) { diff --git a/Terminal.Gui/Views/FrameView.cs b/Terminal.Gui/Views/FrameView.cs index 9ea3e4d0b..9b2a53783 100644 --- a/Terminal.Gui/Views/FrameView.cs +++ b/Terminal.Gui/Views/FrameView.cs @@ -92,8 +92,10 @@ namespace Terminal.Gui { void Initialize () { - base.Add (contentView); - contentView.Text = base.Text; + if (Subviews?.Count == 0) { + base.Add (contentView); + contentView.Text = base.Text; + } } void DrawFrame ()