Sfoglia il codice sorgente

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 anni fa
parent
commit
43ea03bc29

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

@@ -1125,10 +1125,10 @@ namespace Terminal.Gui {
 				return;
 			}
 
-			if (focused != null) {
+			if (focused?.Frame.Width > 0 && focused.Frame.Height > 0) {
 				focused.PositionCursor ();
 			} else {
-				if (CanFocus && HasFocus && Visible) {
+				if (CanFocus && HasFocus && Visible && Frame.Width > 0 && Frame.Height > 0) {
 					Move (textFormatter.HotKeyPos == -1 ? 0 : textFormatter.CursorPosition, 0);
 				} else {
 					Move (frame.X, frame.Y);
@@ -1344,7 +1344,7 @@ namespace Terminal.Gui {
 
 							// Draw the subview
 							// 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);
 							}
 						}
@@ -2133,11 +2133,11 @@ namespace Terminal.Gui {
 
 		bool CanBeVisible (View view)
 		{
-			if (!view.Visible) {
+			if (!view.Visible || view.Frame.Width == 0 || view.Frame.Height == 0) {
 				return false;
 			}
 			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;
 				}
 			}

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

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

+ 5 - 5
UICatalog/Scenarios/Clipping.cs

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

+ 7 - 1
UICatalog/Scenarios/Threading.cs

@@ -92,7 +92,13 @@ namespace UICatalog {
 			_btnQuit.Clicked += Application.RequestStop;
 
 			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 ()