Bläddra i källkod

Fixed a focused issue.

BDisp 5 år sedan
förälder
incheckning
cd2faf5fbd
2 ändrade filer med 5 tillägg och 3 borttagningar
  1. 3 3
      Terminal.Gui/Core/View.cs
  2. 2 0
      Terminal.Gui/Views/Menu.cs

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

@@ -748,6 +748,9 @@ namespace Terminal.Gui {
 					view.SetNeedsDisplay ();
 			}
 			OnRemoved (view);
+			if (focused == view) {
+				focused = null;
+			}
 		}
 
 		void PerformActionForSubview (View subview, Action<View> action)
@@ -1882,9 +1885,6 @@ namespace Terminal.Gui {
 				Remove (subview);
 				subview.Dispose ();
 			}
-			if (Application.Top.focused == this) {
-				Application.Top.focused = null;
-			}
 			base.Dispose (disposing);
 		}
 

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

@@ -1019,11 +1019,13 @@ namespace Terminal.Gui {
 				LastFocused = lastFocused;
 				lastFocused = null;
 				if (LastFocused != null) {
+					CanFocus = false;
 					if (!reopen) {
 						selected = -1;
 					}
 					LastFocused.SuperView?.SetFocus (LastFocused);
 				} else {
+					CanFocus = true;
 					SuperView.SetFocus (this);
 					PositionCursor ();
 				}