소스 검색

Fixed a focused issue.

BDisp 5 년 전
부모
커밋
1cdf6d0587
2개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      Terminal.Gui/Core/View.cs
  2. 2 0
      Terminal.Gui/Views/Menu.cs

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

@@ -777,6 +777,9 @@ namespace Terminal.Gui {
 					view.SetNeedsDisplay ();
 			}
 			OnRemoved (view);
+			if (focused == view) {
+				focused = null;
+			}
 		}
 
 		void PerformActionForSubview (View subview, Action<View> action)
@@ -1911,9 +1914,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 ();
 				}