Bläddra i källkod

Fixes #2071. DrawContentComplete event is never called from the base if it's overridden.

BDisp 2 år sedan
förälder
incheckning
b6715863a3
2 ändrade filer med 19 tillägg och 0 borttagningar
  1. 1 0
      Terminal.Gui/Core/View.cs
  2. 18 0
      UnitTests/ViewTests.cs

+ 1 - 0
Terminal.Gui/Core/View.cs

@@ -1548,6 +1548,7 @@ namespace Terminal.Gui {
 								};
 								view.OnDrawContent (rect);
 								view.Redraw (rect);
+								view.OnDrawContentComplete (rect);
 							}
 						}
 						view.NeedDisplay = Rect.Empty;

+ 18 - 0
UnitTests/ViewTests.cs

@@ -3892,5 +3892,23 @@ This is a tes
 This is a tes
 ", output);
 		}
+
+		[Fact, AutoInitShutdown]
+		public void DrawContentComplete_Event_Is_Always_Called ()
+		{
+			var viewCalled = false;
+			var tvCalled = false;
+
+			var view = new View ("View") { Width = 10, Height = 10 };
+			view.DrawContentComplete += (e) => viewCalled = true;
+			var tv = new TextView () { Y = 11, Width = 10, Height = 10 };
+			tv.DrawContentComplete += (e) => tvCalled = true;
+
+			Application.Top.Add (view, tv);
+			Application.Begin (Application.Top);
+
+			Assert.True (viewCalled);
+			Assert.True (tvCalled);
+		}
 	}
 }