Tig 9 miesięcy temu
rodzic
commit
dc4ce1e418

+ 1 - 1
Terminal.Gui/Application/Application.Mouse.cs

@@ -6,7 +6,7 @@ namespace Terminal.Gui;
 
 public static partial class Application // Mouse handling
 {
-    internal static Point? _lastMousePosition = null;
+    internal static Point? _lastMousePosition;
 
     /// <summary>
     ///     Gets the most recent position of the mouse.

+ 6 - 8
Terminal.Gui/View/View.Command.cs

@@ -106,7 +106,7 @@ public partial class View // Command APIs
     }
 
     /// <summary>
-    ///     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
+    ///     Called when the user is accepting the state of the View and the <see cref="Command.Accept"/> has been invoked. Set CommandEventArgs.Cancel to
     ///     <see langword="true"/> and return <see langword="true"/> to stop processing.
     /// </summary>
     /// <remarks>
@@ -120,7 +120,7 @@ public partial class View // Command APIs
 
     /// <summary>
     ///     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.
+    ///     CommandEventArgs.Cancel to cancel the event.
     /// </summary>
     /// <remarks>
     /// <para>
@@ -159,7 +159,7 @@ public partial class View // Command APIs
 
     /// <summary>
     ///     Called when the user has performed an action (e.g. <see cref="Command.Select"/>) causing the View to change state.
-    ///     Set <see cref="CommandEventArgs.Cancel"/> to
+    ///     Set CommandEventArgs.Cancel to
     ///     <see langword="true"/> and return <see langword="true"/> to cancel the state change. The default implementation does nothing.
     /// </summary>
     /// <param name="args">The event arguments.</param>
@@ -168,8 +168,7 @@ public partial class View // Command APIs
 
     /// <summary>
     ///     Cancelable event raised when the user has performed an action (e.g. <see cref="Command.Select"/>) causing the View to change state.
-    ///     Set <see cref="CommandEventArgs.Cancel"/> to
-    ///     <see langword="true"/> to cancel the state change.
+    ///     CommandEventArgs.Cancel to <see langword="true"/> to cancel the state change.
     /// </summary>
     public event EventHandler<CommandEventArgs>? Selecting;
 
@@ -199,7 +198,7 @@ public partial class View // Command APIs
     }
 
     /// <summary>
-    ///     Called when the View is handling the user pressing the View's <see cref="HotKey"/>. Set <see cref="CommandEventArgs.Cancel"/> to
+    ///     Called when the View is handling the user pressing the View's <see cref="HotKey"/>. Set CommandEventArgs.Cancel to
     ///     <see langword="true"/> to stop processing.
     /// </summary>
     /// <param name="args"></param>
@@ -208,8 +207,7 @@ public partial class View // Command APIs
 
     /// <summary>
     ///     Cancelable event raised when the View is handling the user pressing the View's <see cref="HotKey"/>. Set
-    ///     <see cref="CommandEventArgs.Cancel"/>
-    ///     to cancel the event.
+    ///     CommandEventArgs.Cancel to cancel the event.
     /// </summary>
     public event EventHandler<CommandEventArgs>? HandlingHotKey;
 

+ 1 - 1
Terminal.Gui/Views/MessageBox.cs

@@ -351,7 +351,7 @@ public static class MessageBox
             {
                 var b = new Button
                 {
-                    Text = $"_{s}",
+                    Text = s,
                     Data = count,
                 };
 

+ 8 - 5
UICatalog/Scenarios/Dialogs.cs

@@ -246,13 +246,13 @@ public class Dialogs : Scenario
 
                     button = new ()
                     {
-                        Text = NumberToWords.Convert (buttonId) + " " + char.ConvertFromUtf32 (buttonId + CODE_POINT),
+                        Text = "_" + NumberToWords.Convert (buttonId) + " " + char.ConvertFromUtf32 (buttonId + CODE_POINT),
                         IsDefault = buttonId == 0
                     };
                 }
                 else
                 {
-                    button = new () { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 };
+                    button = new () { Text = "_" + NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 };
                 }
 
                 button.Accepting += (s, e) =>
@@ -270,7 +270,7 @@ public class Dialogs : Scenario
             {
                 Title = titleEdit.Text,
                 Text = "Dialog Text",
-                ButtonAlignment = (Alignment)Enum.Parse (typeof (Alignment), alignmentRadioGroup.RadioLabels [alignmentRadioGroup.SelectedItem].Substring(1)),
+                ButtonAlignment = (Alignment)Enum.Parse (typeof (Alignment), alignmentRadioGroup.RadioLabels [alignmentRadioGroup.SelectedItem].Substring (1)),
 
                 Buttons = buttons.ToArray ()
             };
@@ -300,19 +300,20 @@ public class Dialogs : Scenario
                               {
                                   button = new ()
                                   {
-                                      Text = NumberToWords.Convert (buttonId) + " " + char.ConvertFromUtf32 (buttonId + CODE_POINT),
+                                      Text = "_" + NumberToWords.Convert (buttonId) + " " + char.ConvertFromUtf32 (buttonId + CODE_POINT),
                                       IsDefault = buttonId == 0
                                   };
                               }
                               else
                               {
-                                  button = new () { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 };
+                                  button = new () { Text = "_" + NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 };
                               }
 
                               button.Accepting += (s, e) =>
                                                {
                                                    clicked = buttonId;
                                                    Application.RequestStop ();
+                                                   e.Cancel = true;
                                                };
                               buttons.Add (button);
                               dialog.AddButton (button);
@@ -321,6 +322,7 @@ public class Dialogs : Scenario
                               //{
                               //    button.TabIndex = buttons [buttons.Count - 2].TabIndex + 1;
                               //}
+                              e.Cancel = true;
                           };
             dialog.Add (add);
 
@@ -339,6 +341,7 @@ public class Dialogs : Scenario
                                   }
 
                                   dialog.LayoutSubviews ();
+                                  e.Cancel = true;
                               };
             dialog.Add (addChar);
 

+ 1 - 1
UICatalog/Scenarios/MessageBoxes.cs

@@ -241,7 +241,7 @@ public class MessageBoxes : Scenario
 
                                                for (var i = 0; i < numButtons; i++)
                                                {
-                                                   btns.Add (NumberToWords.Convert (i));
+                                                   btns.Add ($"_{NumberToWords.Convert (i)}");
                                                }
 
                                                if (styleRadioGroup.SelectedItem == 0)

+ 1 - 1
UICatalog/UICatalog.cs

@@ -695,7 +695,7 @@ public class UICatalogApp
 
             MenuBar!.Menus [0].Children! [0]!.ShortcutKey = Application.QuitKey;
 
-            ((Shortcut)_statusBar.Subviews [0]).Key = Application.QuitKey;
+            ((Shortcut)_statusBar!.Subviews [0]).Key = Application.QuitKey;
             _statusBar.Visible = ShowStatusBar;
 
             MiIsMouseDisabled!.Checked = Application.IsMouseDisabled;

+ 1 - 1
UnitTests/Application/ApplicationTests.cs

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

+ 4 - 4
UnitTests/Dialogs/MessageBoxTests.cs

@@ -52,8 +52,8 @@ public class MessageBoxTests
                                  };
         Application.Run ().Dispose ();
 
-        Assert.Equal (0, result);
-        Assert.Equal (btnAcceptCount, 1);
+        Assert.Equal (1, result);
+        Assert.Equal (1, btnAcceptCount);
     }
 
     [Fact]
@@ -134,8 +134,8 @@ public class MessageBoxTests
                                  };
         Application.Run ().Dispose ();
 
-        Assert.Equal (0, result);
-        Assert.Equal (btnAcceptCount, 1);
+        Assert.Equal (1, result);
+        Assert.Equal (1, btnAcceptCount);
 
     }
 

+ 0 - 2
UnitTests/TestHelpers.cs

@@ -140,8 +140,6 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
     }
 
     private bool AutoInit { get; }
-
-    private List<object> _savedValues;
 }
 
 /// <summary>