From eee6099b734ef433ad9de31a540b0135fd600fb6 Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 7 Oct 2024 23:01:05 -0400 Subject: [PATCH] Bdisp feedback fixes --- Terminal.Gui/Application/Application.Mouse.cs | 2 + Terminal.Gui/View/View.Command.cs | 19 ++++++ Terminal.Gui/Views/Button.cs | 62 +++++++++++-------- UICatalog/Scenarios/ProgressBarStyles.cs | 1 - UnitTests/Application/ApplicationTests.cs | 2 +- 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/Terminal.Gui/Application/Application.Mouse.cs b/Terminal.Gui/Application/Application.Mouse.cs index 615c506b5..27e2ba9c2 100644 --- a/Terminal.Gui/Application/Application.Mouse.cs +++ b/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; } diff --git a/Terminal.Gui/View/View.Command.cs b/Terminal.Gui/View/View.Command.cs index 3facab4d0..a75f368cd 100644 --- a/Terminal.Gui/View/View.Command.cs +++ b/Terminal.Gui/View/View.Command.cs @@ -53,7 +53,16 @@ public partial class View // Command APIs /// event. The default handler calls this method. /// /// + /// /// The event should raised after the state of the View has changed (after is raised). + /// + /// + /// If the Accepting event is not handled, will be invoked on the SuperView, enabling default Accept behavior. + /// + /// + /// If a peer-View raises the Accepting event and the event is not cancelled, the will be invoked on the + /// first Button in the SuperView that has set to . + /// /// /// /// If the event was canceled. If 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 has been invoked. Set to /// and return to stop processing. /// + /// + /// + /// See for more information. + /// + /// /// /// to stop processing. 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 has been invoked. Set /// to cancel the event. /// + /// + /// + /// See for more information. + /// + /// public event EventHandler? Accepting; /// diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index b0ab5408f..c10e29545 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -1,29 +1,18 @@ -// -// Button.cs: Button control -// -// Authors: -// Miguel de Icaza (miguel@gnome.org) -// - namespace Terminal.Gui; /// -/// A View that raises the event when clicked with the mouse or when the -/// , Enter, or Space key is pressed. +/// A button View that can be pressed with the mouse or keybaord. /// /// /// -/// Provides a button showing text that raises the event when clicked on with a mouse or -/// when the user presses Enter, Space or the . The hot key is the first -/// letter or digit -/// following the first underscore ('_') in the button text. +/// The Button will raise the event when the user presses , +/// Enter, or Space +/// or clicks on the button with the mouse. /// /// Use to change the hot key specifier from the default of ('_'). /// -/// When the button is configured as the default () and the user causes the button to be -/// accepted the 's event will be raised. If the Accept event is not -/// handled, the Accept event on the . will be raised. This enables default Accept -/// behavior. +/// Button can act as the default handler for all peer-Views. See +/// . /// /// /// Set to 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 e) @@ -166,14 +156,27 @@ public class Button : View, IDesignable } /// - /// Gets or sets whether the will show an indicator indicating it is the default Button. If - /// - /// will be invoked when the user presses Enter and no other peer- - /// processes the key. - /// If is not handled, the Gets or sets whether the will show an - /// indicator indicating it is the default Button. If - /// command on the will be invoked. + /// Gets or sets whether the will act as the default handler for + /// commands on the . /// + /// + /// + /// If : + /// + /// + /// - the Button will display an indicator that it is the default Button. + /// + /// + /// - when clicked, if the Accepting event is not handled, will be + /// invoked on the SuperView. + /// + /// + /// - If a peer-View receives and does not handle it, the command will be passed to + /// the + /// first Button in the SuperView that has set to . See + /// for more information. + /// + /// public bool IsDefault { get => _isDefault; @@ -191,10 +194,15 @@ public class Button : View, IDesignable } } - /// + /// + /// Gets or sets whether the Button will show decorations or not. If the glyphs that normally + /// brakcet the Button Title and the indicator will not be shown. + /// public bool NoDecorations { get; set; } - /// + /// + /// Gets or sets whether the Button will include padding on each side of the Title. + /// public bool NoPadding { get; set; } /// diff --git a/UICatalog/Scenarios/ProgressBarStyles.cs b/UICatalog/Scenarios/ProgressBarStyles.cs index 8a44c7d38..3af7e1405 100644 --- a/UICatalog/Scenarios/ProgressBarStyles.cs +++ b/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; }; diff --git a/UnitTests/Application/ApplicationTests.cs b/UnitTests/Application/ApplicationTests.cs index 449ba8f4a..b23703299 100644 --- a/UnitTests/Application/ApplicationTests.cs +++ b/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);