Sfoglia il codice sorgente

Fix a bug where a focused view was receiving the Leave event.

BDisp 2 anni fa
parent
commit
de909b86cd

+ 0 - 3
Terminal.Gui/Core/Toplevel.cs

@@ -570,9 +570,6 @@ namespace Terminal.Gui {
 		///<inheritdoc/>
 		public override void Remove (View view)
 		{
-			if (InternalSubviews.Count < 1) {
-				CanFocus = false;
-			}
 			if (this is Toplevel toplevel && toplevel.MenuBar != null) {
 				RemoveMenuStatusBar (view);
 			}

+ 0 - 3
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 ();

+ 2 - 1
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]