From b6715863a32394d7e6ca94df81f6505ba99662d3 Mon Sep 17 00:00:00 2001 From: BDisp Date: Wed, 28 Sep 2022 17:16:48 +0100 Subject: [PATCH] Fixes #2071. DrawContentComplete event is never called from the base if it's overridden. --- Terminal.Gui/Core/View.cs | 1 + UnitTests/ViewTests.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index 99afe4b07..67dfdf755 100644 --- a/Terminal.Gui/Core/View.cs +++ b/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; diff --git a/UnitTests/ViewTests.cs b/UnitTests/ViewTests.cs index ef601b46b..3c03abe3f 100644 --- a/UnitTests/ViewTests.cs +++ b/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); + } } }