瀏覽代碼

Fixes #864. FrameView has only one contentView now.

BDisp 5 年之前
父節點
當前提交
0934cab654
共有 2 個文件被更改,包括 16 次插入4 次删除
  1. 12 2
      Terminal.Gui/Core/Toplevel.cs
  2. 4 2
      Terminal.Gui/Views/FrameView.cs

+ 12 - 2
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<View> GetToplevelSubviews (bool isForward)
 		{
 			if (SuperView == null) {

+ 4 - 2
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 ()