浏览代码

In addition to the view visibility having to be true to be redrawn, it is also necessary that the width and height are greater than zero.

BDisp 4 年之前
父节点
当前提交
43ea03bc29
共有 4 个文件被更改,包括 20 次插入11 次删除
  1. 5 5
      Terminal.Gui/Core/View.cs
  2. 3 0
      Terminal.Gui/Views/Menu.cs
  3. 5 5
      UICatalog/Scenarios/Clipping.cs
  4. 7 1
      UICatalog/Scenarios/Threading.cs

+ 5 - 5
Terminal.Gui/Core/View.cs

@@ -1125,10 +1125,10 @@ namespace Terminal.Gui {
 				return;
 				return;
 			}
 			}
 
 
-			if (focused != null) {
+			if (focused?.Frame.Width > 0 && focused.Frame.Height > 0) {
 				focused.PositionCursor ();
 				focused.PositionCursor ();
 			} else {
 			} else {
-				if (CanFocus && HasFocus && Visible) {
+				if (CanFocus && HasFocus && Visible && Frame.Width > 0 && Frame.Height > 0) {
 					Move (textFormatter.HotKeyPos == -1 ? 0 : textFormatter.CursorPosition, 0);
 					Move (textFormatter.HotKeyPos == -1 ? 0 : textFormatter.CursorPosition, 0);
 				} else {
 				} else {
 					Move (frame.X, frame.Y);
 					Move (frame.X, frame.Y);
@@ -1344,7 +1344,7 @@ namespace Terminal.Gui {
 
 
 							// Draw the subview
 							// Draw the subview
 							// Use the view's bounds (view-relative; Location will always be (0,0)
 							// Use the view's bounds (view-relative; Location will always be (0,0)
-							if (view.Visible) {
+							if (view.Visible && view.Frame.Width > 0 && view.Frame.Height > 0) {
 								view.Redraw (view.Bounds);
 								view.Redraw (view.Bounds);
 							}
 							}
 						}
 						}
@@ -2133,11 +2133,11 @@ namespace Terminal.Gui {
 
 
 		bool CanBeVisible (View view)
 		bool CanBeVisible (View view)
 		{
 		{
-			if (!view.Visible) {
+			if (!view.Visible || view.Frame.Width == 0 || view.Frame.Height == 0) {
 				return false;
 				return false;
 			}
 			}
 			for (var c = view.SuperView; c != null; c = c.SuperView) {
 			for (var c = view.SuperView; c != null; c = c.SuperView) {
-				if (!c.Visible) {
+				if (!c.Visible || c.Frame.Width == 0 || c.Frame.Height == 0) {
 					return false;
 					return false;
 				}
 				}
 			}
 			}

+ 3 - 0
Terminal.Gui/Views/Menu.cs

@@ -927,6 +927,9 @@ namespace Terminal.Gui {
 		///<inheritdoc/>
 		///<inheritdoc/>
 		public override void PositionCursor ()
 		public override void PositionCursor ()
 		{
 		{
+			if (selected == -1 && HasFocus && Menus.Length > 0) {
+				selected = 0;
+			}
 			int pos = 0;
 			int pos = 0;
 			for (int i = 0; i < Menus.Length; i++) {
 			for (int i = 0; i < Menus.Length; i++) {
 				if (i == selected) {
 				if (i == selected) {

+ 5 - 5
UICatalog/Scenarios/Clipping.cs

@@ -32,7 +32,7 @@ namespace UICatalog {
 			//Win.Y = 2;
 			//Win.Y = 2;
 			//Win.Width = Dim.Fill () - 4;
 			//Win.Width = Dim.Fill () - 4;
 			//Win.Height = Dim.Fill () - 2;
 			//Win.Height = Dim.Fill () - 2;
-			var label = new Label ("ScrollView (new Rect (5, 5, 100, 60)) with a 200, 100 ContentSize...") {
+			var label = new Label ("ScrollView (new Rect (3, 3, 50, 20)) with a 200, 100 ContentSize...") {
 				X = 0, Y = 0,
 				X = 0, Y = 0,
 				//ColorScheme = Colors.Dialog
 				//ColorScheme = Colors.Dialog
 			};
 			};
@@ -40,10 +40,10 @@ namespace UICatalog {
 
 
 			var scrollView = new ScrollView (new Rect (3, 3, 50, 20));
 			var scrollView = new ScrollView (new Rect (3, 3, 50, 20));
 			scrollView.ColorScheme = Colors.Menu;
 			scrollView.ColorScheme = Colors.Menu;
-			scrollView.ContentSize = new Size (100, 60);
+			scrollView.ContentSize = new Size (200, 100);
 			//ContentOffset = new Point (0, 0),
 			//ContentOffset = new Point (0, 0),
-			scrollView.ShowVerticalScrollIndicator = true;
-			scrollView.ShowHorizontalScrollIndicator = true;
+			//scrollView.ShowVerticalScrollIndicator = true;
+			//scrollView.ShowHorizontalScrollIndicator = true;
 
 
 			var embedded1 = new Window ("1") {
 			var embedded1 = new Window ("1") {
 				X = 3,
 				X = 3,
@@ -78,7 +78,7 @@ namespace UICatalog {
 			embedded2.Add (embedded3);
 			embedded2.Add (embedded3);
 
 
 			scrollView.Add (embedded1);
 			scrollView.Add (embedded1);
-					
+
 			Top.Add (scrollView);
 			Top.Add (scrollView);
 		}
 		}
 	}
 	}

+ 7 - 1
UICatalog/Scenarios/Threading.cs

@@ -92,7 +92,13 @@ namespace UICatalog {
 			_btnQuit.Clicked += Application.RequestStop;
 			_btnQuit.Clicked += Application.RequestStop;
 
 
 			Win.Add (_itemsList, _btnActionCancel, _logJob, text, _btnAction, _btnLambda, _btnHandler, _btnSync, _btnMethod, _btnClearData, _btnQuit);
 			Win.Add (_itemsList, _btnActionCancel, _logJob, text, _btnAction, _btnLambda, _btnHandler, _btnSync, _btnMethod, _btnClearData, _btnQuit);
-			_btnActionCancel.SetFocus ();
+
+			void Top_Loaded ()
+			{
+				_btnActionCancel.SetFocus ();
+				Top.Loaded -= Top_Loaded;
+			}
+			Top.Loaded += Top_Loaded;
 		}
 		}
 
 
 		private async void LoadData ()
 		private async void LoadData ()