Browse Source

Ensures the HasFocus property only can be set by the SetHasFocus method. Removed unnecessary code in Menu.

BDisp 5 years ago
parent
commit
f9d55c9d08
3 changed files with 2 additions and 4 deletions
  1. 1 2
      Terminal.Gui/Core/Responder.cs
  2. 1 0
      Terminal.Gui/Core/View.cs
  3. 0 2
      Terminal.Gui/Views/Menu.cs

+ 1 - 2
Terminal.Gui/Core/Responder.cs

@@ -24,12 +24,11 @@ namespace Terminal.Gui {
 		/// <value><c>true</c> if can focus; otherwise, <c>false</c>.</value>
 		public virtual bool CanFocus { get; set; }
 
-		internal bool hasFocus;
 		/// <summary>
 		/// Gets or sets a value indicating whether this <see cref="Responder"/> has focus.
 		/// </summary>
 		/// <value><c>true</c> if has focus; otherwise, <c>false</c>.</value>
-		public virtual bool HasFocus { get { return hasFocus; } }
+		public virtual bool HasFocus { get; }
 
 		// Key handling
 		/// <summary>

+ 1 - 0
Terminal.Gui/Core/View.cs

@@ -895,6 +895,7 @@ namespace Terminal.Gui {
 			}
 		}
 
+		bool hasFocus;
 		/// <inheritdoc/>
 		public override bool HasFocus {
 			get {

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

@@ -535,8 +535,6 @@ namespace Terminal.Gui {
 				if (item == null || !item.IsEnabled ()) disabled = true;
 				if (item != null && !disabled)
 					current = me.Y - 1;
-				hasFocus = true;
-				SetNeedsDisplay ();
 				CheckSubMenu ();
 				return true;
 			}