Browse Source

Bdisp feedback fixes

Tig 9 months ago
parent
commit
eee6099b73

+ 2 - 0
Terminal.Gui/Application/Application.Mouse.cs

@@ -224,6 +224,8 @@ public static partial class Application // Mouse handling
         {
             // The mouse was outside any View's Viewport.
 
+            Debug.Fail ("This should never happen. If it does please file an Issue!!");
+
             return;
         }
 

+ 19 - 0
Terminal.Gui/View/View.Command.cs

@@ -53,7 +53,16 @@ public partial class View // Command APIs
     ///     event. The default <see cref="Command.Accept"/> handler calls this method.
     /// </summary>
     /// <remarks>
+    /// <para>
     ///     The <see cref="Accepting"/> event should raised after the state of the View has changed (after <see cref="Selecting"/> is raised).
+    /// </para>
+    /// <para>
+    ///    If the Accepting event is not handled, <see cref="Command.Accept"/> will be invoked on the SuperView, enabling default Accept behavior.
+    /// </para>
+    /// <para>
+    ///    If a peer-View raises the Accepting event and the event is not cancelled, the <see cref="Command.Accept"/> will be invoked on the
+    ///    first Button in the SuperView that has <see cref="Button.IsDefault"/> set to <see langword="true"/>.
+    /// </para>
     /// </remarks>
     /// <returns>
     ///     If <see langword="true"/> the event was canceled. If <see langword="false"/> the event was raised but not canceled.
@@ -100,6 +109,11 @@ public partial class View // Command APIs
     ///     Called when the user is accepting the state of the View and the <see cref="Command.Accept"/> has been invoked. Set <see cref="CommandEventArgs.Cancel"/> to
     ///     <see langword="true"/> and return <see langword="true"/> to stop processing.
     /// </summary>
+    /// <remarks>
+    /// <para>
+    ///    See <see cref="View.RaiseAccepting"/> for more information.
+    /// </para>
+    /// </remarks>
     /// <param name="args"></param>
     /// <returns><see langword="true"/> to stop processing.</returns>
     protected virtual bool OnAccepting (CommandEventArgs args) { return false; }
@@ -108,6 +122,11 @@ public partial class View // Command APIs
     ///     Cancelable event raised when the user is accepting the state of the View and the <see cref="Command.Accept"/> has been invoked. Set
     ///     <see cref="CommandEventArgs.Cancel"/> to cancel the event.
     /// </summary>
+    /// <remarks>
+    /// <para>
+    ///    See <see cref="View.RaiseAccepting"/> for more information.
+    /// </para>
+    /// </remarks>
     public event EventHandler<CommandEventArgs>? Accepting;
 
     /// <summary>

+ 35 - 27
Terminal.Gui/Views/Button.cs

@@ -1,29 +1,18 @@
-//
-// Button.cs: Button control
-//
-// Authors:
-//   Miguel de Icaza ([email protected])
-//
-
 namespace Terminal.Gui;
 
 /// <summary>
-///     A View that raises the <see cref="View.Accepting"/> event when clicked with the mouse or when the
-///     <see cref="View.HotKey"/>, <c>Enter</c>, or <c>Space</c> key is pressed.
+///     A button View that can be pressed with the mouse or keybaord.
 /// </summary>
 /// <remarks>
 ///     <para>
-///         Provides a button showing text that raises the <see cref="View.Accepting"/> event when clicked on with a mouse or
-///         when the user presses <c>Enter</c>, <c>Space</c> or the <see cref="View.HotKey"/>. The hot key is the first
-///         letter or digit
-///         following the first underscore ('_') in the button text.
+///         The Button will raise the <see cref="View.Accepting"/> event when the user presses <see cref="View.HotKey"/>,
+///         <c>Enter</c>, or <c>Space</c>
+///         or clicks on the button with the mouse.
 ///     </para>
 ///     <para>Use <see cref="View.HotKeySpecifier"/> to change the hot key specifier from the default of ('_').</para>
 ///     <para>
-///         When the button is configured as the default (<see cref="IsDefault"/>) and the user causes the button to be
-///         accepted the <see cref="Button"/>'s <see cref="View.Accepting"/> event will be raised. If the Accept event is not
-///         handled, the Accept event on the <see cref="View.SuperView"/>. will be raised. This enables default Accept
-///         behavior.
+///         Button can act as the default <see cref="Command.Accept"/> handler for all peer-Views. See
+///         <see cref="IsDefault"/>.
 ///     </para>
 ///     <para>
 ///         Set <see cref="View.WantContinuousButtonPressed"/> to <see langword="true"/> to have the
@@ -142,7 +131,8 @@ public class Button : View, IDesignable
         {
             return;
         }
-        e.Handled = InvokeCommand (Command.HotKey, ctx: new (Command.HotKey, key: null, data: this)) == true;
+
+        e.Handled = InvokeCommand (Command.HotKey, new (Command.HotKey, null, data: this)) == true;
     }
 
     private void Button_TitleChanged (object sender, EventArgs<string> e)
@@ -166,14 +156,27 @@ public class Button : View, IDesignable
     }
 
     /// <summary>
-    ///     Gets or sets whether the <see cref="Button"/> will show an indicator indicating it is the default Button. If
-    ///     <see langword="true"/>
-    ///     <see cref="Command.Accept"/> will be invoked when the user presses <c>Enter</c> and no other peer-
-    ///     <see cref="View"/> processes the key.
-    ///     If <see cref="View.Accepting"/> is not handled, the Gets or sets whether the <see cref="Button"/> will show an
-    ///     indicator indicating it is the default Button. If <see langword="true"/>
-    ///     <see cref="Command.Accept"/> command on the <see cref="View.SuperView"/> will be invoked.
+    ///     Gets or sets whether the <see cref="Button"/> will act as the default handler for <see cref="Command.Accept"/>
+    ///     commands on the <see cref="View.SuperView"/>.
     /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If <see langword="true"/>:
+    ///     </para>
+    ///     <para>
+    ///         - the Button will display an indicator that it is the default Button.
+    ///     </para>
+    ///     <para>
+    ///         - when clicked, if the Accepting event is not handled, <see cref="Command.Accept"/> will be
+    ///         invoked on the SuperView.
+    ///     </para>
+    ///     <para>
+    ///         - If a peer-View receives <see cref="Command.Accept"/> and does not handle it, the command will be passed to
+    ///         the
+    ///         first Button in the SuperView that has <see cref="IsDefault"/> set to <see langword="true"/>. See
+    ///         <see cref="View.RaiseAccepting"/> for more information.
+    ///     </para>
+    /// </remarks>
     public bool IsDefault
     {
         get => _isDefault;
@@ -191,10 +194,15 @@ public class Button : View, IDesignable
         }
     }
 
-    /// <summary></summary>
+    /// <summary>
+    ///     Gets or sets whether the Button will show decorations or not. If <see langword="true"/> the glyphs that normally
+    ///     brakcet the Button Title and the <see cref="IsDefault"/> indicator will not be shown.
+    /// </summary>
     public bool NoDecorations { get; set; }
 
-    /// <summary></summary>
+    /// <summary>
+    ///     Gets or sets whether the Button will include padding on each side of the Title.
+    /// </summary>
     public bool NoPadding { get; set; }
 
     /// <inheritdoc/>

+ 0 - 1
UICatalog/Scenarios/ProgressBarStyles.cs

@@ -264,7 +264,6 @@ public class ProgressBarStyles : Scenario
 
         ckbBidirectional.CheckedStateChanging += (s, e) =>
                                    {
-                                       ckbBidirectional.CheckedState = e.NewValue;
                                        marqueesBlocksPB.BidirectionalMarquee =
                                                                   marqueesContinuousPB.BidirectionalMarquee = e.NewValue == CheckState.Checked;
                                    };

+ 1 - 1
UnitTests/Application/ApplicationTests.cs

@@ -319,7 +319,7 @@ public class ApplicationTests
             Assert.Empty (Application.GetViewKeyBindings ());
 
             // Mouse
-            Assert.Equal (Point.Empty, Application._lastMousePosition);
+            Assert.Equal (null, Application._lastMousePosition);
 
             // Navigation
             Assert.Null (Application.Navigation);