Przeglądaj źródła

Moved HasFocus out of Responder and made non-virtual

Tig Kindel 1 rok temu
rodzic
commit
5607f530e4

+ 0 - 4
Terminal.Gui/Input/Responder.cs

@@ -26,10 +26,6 @@ public class Responder : IDisposable
     /// <summary>Gets or sets a value indicating whether this <see cref="Responder"/> can respond to user interaction.</summary>
     public virtual bool Enabled { get; set; } = true;
 
-    /// <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; }
-
     /// <summary>Gets or sets a value indicating whether this <see cref="Responder"/> and all its child controls are displayed.</summary>
     public virtual bool Visible { get; set; } = true;
 

+ 6 - 3
Terminal.Gui/View/ViewSubViews.cs

@@ -316,15 +316,18 @@ public partial class View
         }
     }
 
-    // BUGBUG: v2 - Seems weird that this is in View and not Responder.
     private bool _hasFocus;
 
     /// <inheritdoc/>
-    public override bool HasFocus => _hasFocus;
+    public bool HasFocus
+    {
+        set => SetHasFocus (value, this, true);
+        get { return _hasFocus; }
+    }
 
     private void SetHasFocus (bool value, View view, bool force = false)
     {
-        if (_hasFocus != value || force)
+        if (HasFocus != value || force)
         {
             _hasFocus = value;
 

+ 0 - 4
Terminal.Gui/Views/Toplevel.cs

@@ -139,10 +139,6 @@ public partial class Toplevel : View
         e.Handled = InvokeCommand (Command.HotKey) == true;
     }
 
-    /// <summary>Gets or sets a value indicating whether this <see cref="Toplevel"/> can focus.</summary>
-    /// <value><c>true</c> if can focus; otherwise, <c>false</c>.</value>
-    //public override bool CanFocus => SuperView is null ? true : base.CanFocus;
-
     /// <summary>
     ///     <see langword="true"/> if was already loaded by the <see cref="Application.Begin(Toplevel)"/>
     ///     <see langword="false"/>, otherwise.

+ 0 - 1
UnitTests/Input/ResponderTests.cs

@@ -222,7 +222,6 @@ public class ResponderTests
         var r = new Responder ();
         Assert.NotNull (r);
         Assert.Equal ("Terminal.Gui.Responder", r.ToString ());
-        Assert.False (r.HasFocus);
         Assert.True (r.Enabled);
         Assert.True (r.Visible);
         r.Dispose ();