From de909b86cdbc95c025f80c149f65580f68b1ff83 Mon Sep 17 00:00:00 2001 From: BDisp Date: Tue, 15 Aug 2023 16:29:07 +0100 Subject: [PATCH] Fix a bug where a focused view was receiving the Leave event. --- Terminal.Gui/Core/Toplevel.cs | 3 --- Terminal.Gui/Core/Window.cs | 3 --- UnitTests/TopLevels/ToplevelTests.cs | 3 ++- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Terminal.Gui/Core/Toplevel.cs b/Terminal.Gui/Core/Toplevel.cs index 3b4689a47..04f8995e8 100644 --- a/Terminal.Gui/Core/Toplevel.cs +++ b/Terminal.Gui/Core/Toplevel.cs @@ -570,9 +570,6 @@ namespace Terminal.Gui { /// public override void Remove (View view) { - if (InternalSubviews.Count < 1) { - CanFocus = false; - } if (this is Toplevel toplevel && toplevel.MenuBar != null) { RemoveMenuStatusBar (view); } diff --git a/Terminal.Gui/Core/Window.cs b/Terminal.Gui/Core/Window.cs index 53925f258..febb7517e 100644 --- a/Terminal.Gui/Core/Window.cs +++ b/Terminal.Gui/Core/Window.cs @@ -270,9 +270,6 @@ namespace Terminal.Gui { SetNeedsDisplay (); contentView.Remove (view); - if (contentView.InternalSubviews.Count < 1) { - CanFocus = false; - } RemoveMenuStatusBar (view); if (view != contentView && Focused == null) { FocusFirst (); diff --git a/UnitTests/TopLevels/ToplevelTests.cs b/UnitTests/TopLevels/ToplevelTests.cs index c76e0ad04..db3921d07 100644 --- a/UnitTests/TopLevels/ToplevelTests.cs +++ b/UnitTests/TopLevels/ToplevelTests.cs @@ -1009,7 +1009,8 @@ namespace Terminal.Gui.TopLevelTests { Application.End (rs); Assert.True (isEnter); - Assert.True (isLeave); // Leave event is now also invoked on Application.End allowing preform same output action + Assert.False (isLeave); // Leave event cannot be trigger because it v.Enter was performed and v is focused + Assert.True (v.HasFocus); } [Fact, AutoInitShutdown]