Răsfoiți Sursa

Fixes #4023 - Changes `CommandEventArgs` to be based on `HandledEventArgs` instead of `CancelEventArgs` (#4054)

* touching publish.yml

* CancelEventArgs->HandledEventArgs

* Fixed Handled issues
Tig 4 luni în urmă
părinte
comite
6f6c2d3320
51 a modificat fișierele cu 261 adăugiri și 229 ștergeri
  1. 4 4
      Examples/CommunityToolkitExample/LoginView.cs
  2. 2 2
      Examples/Example/Example.cs
  3. 2 2
      Examples/NativeAot/Program.cs
  4. 4 3
      Examples/ReactiveExample/LoginViewModel.cs
  5. 2 2
      Examples/SelfContained/Program.cs
  6. 1 1
      Examples/UICatalog/Scenarios/Adornments.cs
  7. 1 1
      Examples/UICatalog/Scenarios/AllViewsTester.cs
  8. 2 2
      Examples/UICatalog/Scenarios/Bars.cs
  9. 16 16
      Examples/UICatalog/Scenarios/Buttons.cs
  10. 1 1
      Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs
  11. 5 5
      Examples/UICatalog/Scenarios/Dialogs.cs
  12. 1 1
      Examples/UICatalog/Scenarios/Editors/DimEditor.cs
  13. 1 1
      Examples/UICatalog/Scenarios/Editors/PosEditor.cs
  14. 1 1
      Examples/UICatalog/Scenarios/FileDialogExamples.cs
  15. 2 2
      Examples/UICatalog/Scenarios/Generic.cs
  16. 2 2
      Examples/UICatalog/Scenarios/LineDrawing.cs
  17. 6 6
      Examples/UICatalog/Scenarios/Menus.cs
  18. 1 1
      Examples/UICatalog/Scenarios/MessageBoxes.cs
  19. 6 6
      Examples/UICatalog/Scenarios/Shortcuts.cs
  20. 1 1
      Examples/UICatalog/Scenarios/SimpleDialog.cs
  21. 1 1
      Examples/UICatalog/Scenarios/Sliders.cs
  22. 1 1
      Examples/UICatalog/Scenarios/Text.cs
  23. 1 1
      Examples/UICatalog/UICatalogTop.cs
  24. 4 4
      Terminal.Gui/FileServices/DefaultFileOperations.cs
  25. 3 2
      Terminal.Gui/Input/CommandEventArgs.cs
  26. 1 1
      Terminal.Gui/View/Adornment/Border.cs
  27. 131 101
      Terminal.Gui/View/View.Command.cs
  28. 1 1
      Terminal.Gui/Views/CheckBox.cs
  29. 2 2
      Terminal.Gui/Views/ColorPicker.Prompt.cs
  30. 1 1
      Terminal.Gui/Views/ComboBox.cs
  31. 7 7
      Terminal.Gui/Views/FileDialog.cs
  32. 2 2
      Terminal.Gui/Views/FlagSelector.cs
  33. 4 4
      Terminal.Gui/Views/Menu/PopoverMenu.cs
  34. 1 1
      Terminal.Gui/Views/MessageBox.cs
  35. 3 3
      Terminal.Gui/Views/NumericUpDown.cs
  36. 2 2
      Terminal.Gui/Views/OptionSelector.cs
  37. 2 2
      Terminal.Gui/Views/ScrollBar/ScrollBar.cs
  38. 2 2
      Terminal.Gui/Views/Shortcut.cs
  39. 1 1
      Terminal.Gui/Views/StatusBar.cs
  40. 3 3
      Terminal.Gui/Views/Wizard/Wizard.cs
  41. 4 4
      Tests/UnitTests/View/ViewCommandTests.cs
  42. 4 4
      Tests/UnitTests/Views/ButtonTests.cs
  43. 3 3
      Tests/UnitTests/Views/CheckBoxTests.cs
  44. 1 1
      Tests/UnitTests/Views/ListViewTests.cs
  45. 2 2
      Tests/UnitTests/Views/RadioGroupTests.cs
  46. 3 3
      Tests/UnitTests/Views/ShortcutTests.cs
  47. 1 1
      Tests/UnitTests/Views/TextFieldTests.cs
  48. 1 1
      Tests/UnitTests/Views/TextViewTests.cs
  49. 1 1
      Tests/UnitTests/Views/TreeViewTests.cs
  50. 6 6
      Tests/UnitTestsParallelizable/View/ViewCommandTests.cs
  51. 1 1
      Tests/UnitTestsParallelizable/Views/TextFieldTests.cs

+ 4 - 4
Examples/CommunityToolkitExample/LoginView.cs

@@ -23,15 +23,15 @@ internal partial class LoginView : IRecipient<Message<LoginActions>>
                               {
                                   if (!ViewModel.CanLogin) { return; }
                                   ViewModel.LoginCommand.Execute (null);
-                                  // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                                  e.Cancel = false;
+                                  // When Accepting is handled, set e.Handled to true to prevent further processing.
+                                  e.Handled = true;
                               };
 
         clearButton.Accepting += (_, e) =>
                               {
                                   ViewModel.ClearCommand.Execute (null);
-                                  // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                                  e.Cancel = false;
+                                  // When Accepting is handled, set e.Handled to true to prevent further processing.
+                                  e.Handled = true;
                               };
 
         Initialized += (_, _) => { ViewModel.Initialized (); };

+ 2 - 2
Examples/Example/Example.cs

@@ -78,8 +78,8 @@ public class ExampleWindow : Window
                                {
                                    MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
                                }
-                               // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                               e.Cancel = false;
+                               // When Accepting is handled, set e.Handled to true to prevent further processing.
+                               e.Handled = true;
                            };
 
         // Add the views to the Window

+ 2 - 2
Examples/NativeAot/Program.cs

@@ -105,8 +105,8 @@ public class ExampleWindow : Window
             {
                 MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
             }
-            // Anytime Accepting is handled, make sure to set e.Cancel to false.
-            e.Cancel = false;
+            // Anytime Accepting is handled, make sure to set e.Handled to true.
+            e.Handled = true;
         };
 
         // Add the views to the Window

+ 4 - 3
Examples/ReactiveExample/LoginViewModel.cs

@@ -6,6 +6,7 @@ using System.Runtime.Serialization;
 using System.Threading.Tasks;
 using ReactiveUI;
 using ReactiveUI.SourceGenerators;
+using Terminal.Gui;
 
 namespace ReactiveExample;
 
@@ -50,7 +51,7 @@ public partial class LoginViewModel : ReactiveObject
 
         _isValidHelper = canLogin.ToProperty (this, x => x.IsValid);
 
-        Login = ReactiveCommand.CreateFromTask<HandledEventArgs>
+        Login = ReactiveCommand.CreateFromTask<CommandEventArgs>
             (
                 e => Task.Delay (TimeSpan.FromSeconds (1)),
                 canLogin
@@ -76,8 +77,8 @@ public partial class LoginViewModel : ReactiveObject
     }
 
     [ReactiveCommand]
-    public void Clear (HandledEventArgs args) { }
+    public void Clear (CommandEventArgs args) { }
 
     [IgnoreDataMember]
-    public ReactiveCommand<HandledEventArgs, Unit> Login { get; }
+    public ReactiveCommand<CommandEventArgs, Unit> Login { get; }
 }

+ 2 - 2
Examples/SelfContained/Program.cs

@@ -104,8 +104,8 @@ public class ExampleWindow : Window
                                {
                                    MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
                                }
-                               // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                               e.Cancel = false;
+                               // When Accepting is handled, set e.Handled to true to prevent further processing.
+                               e.Handled = true;
                            };
 
         // Add the views to the Window

+ 1 - 1
Examples/UICatalog/Scenarios/Adornments.cs

@@ -143,7 +143,7 @@ public class Adornments : Scenario
                                 view.Border.CloseButton.Accept += (s, e) =>
                                                                   {
                                                                       MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");
-                                                                      e.Cancel = true;
+                                                                      e.Handled = true;
                                                                   };
 
                                 view.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");

+ 1 - 1
Examples/UICatalog/Scenarios/AllViewsTester.cs

@@ -83,7 +83,7 @@ public class AllViewsTester : Scenario
         _classListView.Accepting += (sender, args) =>
                                     {
                                         _curView?.SetFocus ();
-                                        args.Cancel = true;
+                                        args.Handled = true;
                                     };
 
         _adornmentsEditor = new ()

+ 2 - 2
Examples/UICatalog/Scenarios/Bars.cs

@@ -486,7 +486,7 @@ public class Bars : Scenario
             CanFocus = false
         };
         // This ensures the checkbox state toggles when the hotkey of Title is pressed.
-        shortcut4.Accepting += (sender, args) => args.Cancel = true;
+        shortcut4.Accepting += (sender, args) => args.Handled = true;
 
         bar.Add (shortcut1, shortcut2, shortcut3, line, shortcut4);
     }
@@ -536,7 +536,7 @@ public class Bars : Scenario
                                                     {
                                                         button1.Visible = !button1.Visible;
                                                         button1.Enabled = button1.Visible;
-                                                        e.Cancel = false;
+                                                        e.Handled = true;
                                                     };
 
         bar.Add (new Label

+ 16 - 16
Examples/UICatalog/Scenarios/Buttons.cs

@@ -49,16 +49,16 @@ public class Buttons : Scenario
 
         swapButton.Accepting += (s, e) =>
                              {
-                                 e.Cancel = !swapButton.IsDefault;
+                                 e.Handled = !swapButton.IsDefault;
                                  defaultButton.IsDefault = !defaultButton.IsDefault;
                                  swapButton.IsDefault = !swapButton.IsDefault;
                              };
 
         defaultButton.Accepting += (s, e) =>
                                 {
-                                    e.Cancel = !defaultButton.IsDefault;
+                                    e.Handled = !defaultButton.IsDefault;
 
-                                    if (e.Cancel)
+                                    if (e.Handled)
                                     {
                                         MessageBox.ErrorQuery ("Error", "This button is no longer the Quit button; the Swap Default button is.", "_Ok");
                                     }
@@ -71,7 +71,7 @@ public class Buttons : Scenario
                              {
                                  string btnText = button.Text;
                                  MessageBox.Query ("Message", $"Did you click {txt}?", "Yes", "No");
-                                 e.Cancel = true;
+                                 e.Handled = true;
                              };
         }
 
@@ -114,7 +114,7 @@ public class Buttons : Scenario
         button.Accepting += (s, e) =>
                          {
                              MessageBox.Query ("Message", "Question?", "Yes", "No");
-                             e.Cancel = true;
+                             e.Handled = true;
                          };
 
         var textChanger = new Button { X = 2, Y = Pos.Bottom (button) + 1, Text = "Te_xt Changer" };
@@ -122,7 +122,7 @@ public class Buttons : Scenario
         textChanger.Accepting += (s, e) =>
                               {
                                   textChanger.Text += "!";
-                                  e.Cancel = true;
+                                  e.Handled = true;
                               };
 
         main.Add (
@@ -133,7 +133,7 @@ public class Buttons : Scenario
                       Text = "Lets see if this will move as \"Text Changer\" grows"
                   }
                  );
-        button.Accepting += (sender, args) => { args.Cancel = true; };
+        button.Accepting += (sender, args) => { args.Handled = true; };
 
         var removeButton = new Button
         {
@@ -146,7 +146,7 @@ public class Buttons : Scenario
         removeButton.Accepting += (s, e) =>
                                {
                                    removeButton.Visible = false;
-                                   e.Cancel = true;
+                                   e.Handled = true;
                                };
 
         var computedFrame = new FrameView
@@ -172,7 +172,7 @@ public class Buttons : Scenario
         moveBtn.Accepting += (s, e) =>
                           {
                               moveBtn.X = moveBtn.Frame.X + 5;
-                              e.Cancel = true;
+                              e.Handled = true;
                           };
         computedFrame.Add (moveBtn);
 
@@ -189,7 +189,7 @@ public class Buttons : Scenario
         sizeBtn.Accepting += (s, e) =>
                           {
                               sizeBtn.Width = sizeBtn.Frame.Width + 5;
-                              e.Cancel = true;
+                              e.Handled = true;
                           };
         computedFrame.Add (sizeBtn);
 
@@ -214,7 +214,7 @@ public class Buttons : Scenario
                                                      moveBtnA.Frame.Width,
                                                      moveBtnA.Frame.Height
                                                     );
-                               e.Cancel = true;
+                               e.Handled = true;
                            };
         absoluteFrame.Add (moveBtnA);
 
@@ -232,7 +232,7 @@ public class Buttons : Scenario
                                                      sizeBtnA.Frame.Width + 5,
                                                      sizeBtnA.Frame.Height
                                                     );
-                               e.Cancel = true;
+                               e.Handled = true;
                            };
         absoluteFrame.Add (sizeBtnA);
 
@@ -300,7 +300,7 @@ public class Buttons : Scenario
         moveHotKeyBtn.Accepting += (s, e) =>
                                 {
                                     moveHotKeyBtn.Text = MoveHotkey (moveHotKeyBtn.Text);
-                                    e.Cancel = true;
+                                    e.Handled = true;
                                 };
         main.Add (moveHotKeyBtn);
 
@@ -317,7 +317,7 @@ public class Buttons : Scenario
         moveUnicodeHotKeyBtn.Accepting += (s, e) =>
                                        {
                                            moveUnicodeHotKeyBtn.Text = MoveHotkey (moveUnicodeHotKeyBtn.Text);
-                                           e.Cancel = true;
+                                           e.Handled = true;
                                        };
         main.Add (moveUnicodeHotKeyBtn);
 
@@ -401,7 +401,7 @@ public class Buttons : Scenario
         noRepeatButton.Accepting += (s, e) =>
                                  {
                                      noRepeatButton.Title = $"Accept Cou_nt: {++noRepeatAcceptCount}";
-                                     e.Cancel = true;
+                                     e.Handled = true;
                                  };
         main.Add (label, noRepeatButton);
 
@@ -423,7 +423,7 @@ public class Buttons : Scenario
         repeatButton.Accepting += (s, e) =>
                                {
                                    repeatButton.Title = $"Accept Co_unt: {++acceptCount}";
-                                   e.Cancel = true;
+                                   e.Handled = true;
                                };
 
         var enableCB = new CheckBox

+ 1 - 1
Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs

@@ -256,7 +256,7 @@ public class CharacterMap : Scenario
             _charMap.SetFocus ();
 
             // Cancel the event to prevent ENTER from being handled elsewhere
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 

+ 5 - 5
Examples/UICatalog/Scenarios/Dialogs.cs

@@ -198,7 +198,7 @@ public class Dialogs : Scenario
                                                                      );
                                        Application.Run (dlg);
                                        dlg.Dispose ();
-                                       e.Cancel = true;
+                                       e.Handled = true;
                                    };
 
         app.Add (showDialogButton);
@@ -258,7 +258,7 @@ public class Dialogs : Scenario
                 button.Accepting += (s, e) =>
                                  {
                                      clicked = buttonId;
-                                     e.Cancel = true;
+                                     e.Handled = true;
                                      Application.RequestStop ();
                                  };
                 buttons.Add (button);
@@ -313,7 +313,7 @@ public class Dialogs : Scenario
                                                {
                                                    clicked = buttonId;
                                                    Application.RequestStop ();
-                                                   e.Cancel = true;
+                                                   e.Handled = true;
                                                };
                               buttons.Add (button);
                               dialog.AddButton (button);
@@ -322,7 +322,7 @@ public class Dialogs : Scenario
                               //{
                               //    button.TabIndex = buttons [buttons.Count - 2].TabIndex + 1;
                               //}
-                              e.Cancel = true;
+                              e.Handled = true;
                           };
             dialog.Add (add);
 
@@ -340,7 +340,7 @@ public class Dialogs : Scenario
                                       button.Text += char.ConvertFromUtf32 (CODE_POINT);
                                   }
 
-                                  e.Cancel = true;
+                                  e.Handled = true;
                               };
             dialog.Add (addChar);
 

+ 1 - 1
Examples/UICatalog/Scenarios/Editors/DimEditor.cs

@@ -114,7 +114,7 @@ public class DimEditor : EditorBase
             {
                 // ignored
             }
-            args.Cancel = true;
+            args.Handled = true;
         };
         Add (_valueEdit);
 

+ 1 - 1
Examples/UICatalog/Scenarios/Editors/PosEditor.cs

@@ -115,7 +115,7 @@ public class PosEditor : EditorBase
                                         // ignored
                                     }
 
-                                    args.Cancel = true;
+                                    args.Handled = true;
                                 };
         Add (_valueEdit);
 

+ 1 - 1
Examples/UICatalog/Scenarios/FileDialogExamples.cs

@@ -141,7 +141,7 @@ public class FileDialogExamples : Scenario
                             }
                             finally
                             {
-                                e.Cancel = true;
+                                e.Handled = true;
                             }
                         };
         win.Add (btn);

+ 2 - 2
Examples/UICatalog/Scenarios/Generic.cs

@@ -39,8 +39,8 @@ public sealed class Generic : Scenario
 
         button.Accepting += (s, e) =>
                             {
-                                // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                                e.Cancel = true;
+                                // When Accepting is handled, set e.Handled to true to prevent further processing.
+                                e.Handled = true;
                                 MessageBox.ErrorQuery ("Error", "You pressed the button!", "_Ok");
                             };
 

+ 2 - 2
Examples/UICatalog/Scenarios/LineDrawing.cs

@@ -153,7 +153,7 @@ public class LineDrawing : Scenario
         btnOk.Accepting += (s, e) =>
                         {
                             accept = true;
-                            e.Cancel = true;
+                            e.Handled = true;
                             Application.RequestStop ();
                         };
 
@@ -167,7 +167,7 @@ public class LineDrawing : Scenario
 
         btnCancel.Accepting += (s, e) =>
                             {
-                                e.Cancel = true;
+                                e.Handled = true;
                                 Application.RequestStop ();
                             };
 

+ 6 - 6
Examples/UICatalog/Scenarios/Menus.cs

@@ -53,7 +53,7 @@ public class Menus : Scenario
 
         menuHostView.CommandNotBound += (o, args) =>
                                         {
-                                            if (o is not View sender || args.Cancel)
+                                            if (o is not View sender || args.Handled)
                                             {
                                                 return;
                                             }
@@ -65,7 +65,7 @@ public class Menus : Scenario
 
         menuHostView.Accepting += (o, args) =>
                                   {
-                                      if (o is not View sender || args.Cancel)
+                                      if (o is not View sender || args.Handled)
                                       {
                                           return;
                                       }
@@ -77,7 +77,7 @@ public class Menus : Scenario
 
         menuHostView.ContextMenu!.Accepted += (o, args) =>
                                               {
-                                                  if (o is not View sender || args.Cancel)
+                                                  if (o is not View sender || args.Handled)
                                                   {
                                                       return;
                                                   }
@@ -263,7 +263,7 @@ public class Menus : Scenario
                                         Logging.Debug ($"menuBar.Accepted: {args.Context.Source?.Title}");
 
                                         // Set Cancel to true to stop propagation of Accepting to superview
-                                        args.Cancel = true;
+                                        args.Handled = true;
 
                                         // Since overwrite uses a MenuItem.Command the menu item CB is the source of truth
                                         enableOverwriteStatusCb.CheckedState = ((CheckBox)mi.CommandView).CheckedState;
@@ -308,7 +308,7 @@ public class Menus : Scenario
                                         Logging.Debug ($"menuBar.Accepted: {args.Context.Source?.Title}");
 
                                         // Set Cancel to true to stop propagation of Accepting to superview
-                                        args.Cancel = true;
+                                        args.Handled = true;
 
                                         // Since overwrite uses a MenuItem.Command the menu item CB is the source of truth
                                         editModeMenuItemCb.CheckedState = ((CheckBox)mi.CommandView).CheckedState;
@@ -363,7 +363,7 @@ public class Menus : Scenario
 
             openBtn.Accepting += (s, e) =>
                                  {
-                                     e.Cancel = true;
+                                     e.Handled = true;
                                      Logging.Trace ($"openBtn.Accepting - Sending F9. {e.Context?.Source?.Title}");
                                      NewKeyDownEvent (menuBar.Key);
                                  };

+ 1 - 1
Examples/UICatalog/Scenarios/MessageBoxes.cs

@@ -279,7 +279,7 @@ public class MessageBoxes : Scenario
                                                buttonPressedLabel.Text = "Invalid Options";
                                            }
 
-                                           e.Cancel = true;
+                                           e.Handled = true;
                                        };
         app.Add (showMessageBoxButton);
 

+ 6 - 6
Examples/UICatalog/Scenarios/Shortcuts.cs

@@ -426,7 +426,7 @@ public class Shortcuts : Scenario
                                              return;
                                          }
                                          bgColor.SelectedColor++;
-                                         args.Cancel = true;
+                                         args.Handled = true;
                                      };
 
         bgColor.ColorChanged += (o, args) =>
@@ -467,7 +467,7 @@ public class Shortcuts : Scenario
         {
             shortcut.Selecting += (o, args) =>
             {
-                if (args.Cancel)
+                if (args.Handled)
                 {
                     return;
                 }
@@ -477,13 +477,13 @@ public class Shortcuts : Scenario
 
             shortcut.CommandView.Selecting += (o, args) =>
             {
-                if (args.Cancel)
+                if (args.Handled)
                 {
                     return;
                 }
                 eventSource.Add ($"{shortcut!.Id}.CommandView.Selecting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
                 eventLog.MoveDown ();
-                args.Cancel = true;
+                args.Handled = true;
             };
 
             shortcut.Accepting += (o, args) =>
@@ -491,7 +491,7 @@ public class Shortcuts : Scenario
                 eventSource.Add ($"{shortcut!.Id}.Accepting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
                 eventLog.MoveDown ();
                 // We don't want this to exit the Scenario
-                args.Cancel = true;
+                args.Handled = true;
             };
 
             shortcut.CommandView.Accepting += (o, args) =>
@@ -505,7 +505,7 @@ public class Shortcuts : Scenario
 
     private void Button_Clicked (object? sender, CommandEventArgs e)
     {
-        e.Cancel = true;
+        e.Handled = true;
         View? view = sender as View;
         MessageBox.Query ("Hi", $"You clicked {view?.Text}", "_Ok");
     }

+ 1 - 1
Examples/UICatalog/Scenarios/SimpleDialog.cs

@@ -44,7 +44,7 @@ public sealed class SimpleDialog : Scenario
         button.Accepting += (s, e) =>
                             {
                                 Application.Run (dialog);
-                                e.Cancel = true;
+                                e.Handled = true;
                             };
         appWindow.Add (button);
 

+ 1 - 1
Examples/UICatalog/Scenarios/Sliders.cs

@@ -591,7 +591,7 @@ public class Sliders : Scenario
                              {
                                  eventSource.Add ($"Accept: {string.Join(",", slider.GetSetOptions ())}");
                                  eventLog.MoveDown ();
-                                 args.Cancel = true;
+                                 args.Handled = true;
                              };
             slider.OptionsChanged += (o, args) =>
                              {

+ 1 - 1
Examples/UICatalog/Scenarios/Text.cs

@@ -452,7 +452,7 @@ public class Text : Scenario
 
         void WinOnAccept (object sender, CommandEventArgs e)
         {
-            e.Cancel = true; // Don't let it close
+            e.Handled = true; // Don't let it close
 
             acceptView.Text = $"Accept was Invoked via {win.Focused.GetType().Name}";
 

+ 1 - 1
Examples/UICatalog/UICatalogTop.cs

@@ -611,7 +611,7 @@ public class UICatalogTop : Toplevel
         statusBarShortcut.Accepting += (sender, args) =>
         {
             statusBar.Visible = !_statusBar!.Visible;
-            args.Cancel = true;
+            args.Handled = true;
         };
 
         _force16ColorsShortcutCb = new ()

+ 4 - 4
Terminal.Gui/FileServices/DefaultFileOperations.cs

@@ -139,8 +139,8 @@ public class DefaultFileOperations : IFileOperations
                          {
                              confirm = true;
                              Application.RequestStop ();
-                             // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                             e.Cancel = false;
+                             // When Accepting is handled, set e.Handled to true to prevent further processing.
+                             e.Handled = true;
                          };
         var btnCancel = new Button { Text = Strings.btnCancel };
 
@@ -148,8 +148,8 @@ public class DefaultFileOperations : IFileOperations
                              {
                                  confirm = false;
                                  Application.RequestStop ();
-                                 // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                                 e.Cancel = false;
+                                 // When Accepting is handled, set e.Handled to true to prevent further processing.
+                                 e.Handled = true;
                              };
 
         var lbl = new Label { Text = Strings.fdRenamePrompt };

+ 3 - 2
Terminal.Gui/Input/CommandEventArgs.cs

@@ -4,9 +4,10 @@ using System.ComponentModel;
 namespace Terminal.Gui;
 
 /// <summary>
-///     Event arguments for <see cref="Command"/> events.
+///     Event arguments for <see cref="Command"/> events. Set <see cref="HandledEventArgs.Handled"/> to
+///     <see langword="true"/> to indicate a command was handled.
 /// </summary>
-public class CommandEventArgs : CancelEventArgs
+public class CommandEventArgs : HandledEventArgs
 {
     /// <summary>
     ///     The context for the command, if any.

+ 1 - 1
Terminal.Gui/View/Adornment/Border.cs

@@ -133,7 +133,7 @@ public class Border : Adornment
             };
             CloseButton.Accept += (s, e) =>
             {
-                e.Cancel = Parent.InvokeCommand (Command.QuitToplevel) == true;
+                e.Handled = Parent.InvokeCommand (Command.QuitToplevel) == true;
             };
             Add (CloseButton);
 

+ 131 - 101
Terminal.Gui/View/View.Command.cs

@@ -1,7 +1,4 @@
 #nullable enable
-using System.ComponentModel;
-using System.Dynamic;
-
 namespace Terminal.Gui;
 
 public partial class View // Command APIs
@@ -22,7 +19,8 @@ public partial class View // Command APIs
         AddCommand (Command.Accept, RaiseAccepting);
 
         // HotKey - SetFocus and raise HandlingHotKey
-        AddCommand (Command.HotKey,
+        AddCommand (
+                    Command.HotKey,
                     () =>
                     {
                         if (RaiseHandlingHotKey () is true)
@@ -36,22 +34,24 @@ public partial class View // Command APIs
                     });
 
         // Space or single-click - Raise Selecting
-        AddCommand (Command.Select, ctx =>
-                                    {
-                                        if (RaiseSelecting (ctx) is true)
-                                        {
-                                            return true;
-                                        }
-
-                                        if (CanFocus)
-                                        {
-                                            SetFocus ();
-
-                                            return true;
-                                        }
-
-                                        return false;
-                                    });
+        AddCommand (
+                    Command.Select,
+                    ctx =>
+                    {
+                        if (RaiseSelecting (ctx) is true)
+                        {
+                            return true;
+                        }
+
+                        if (CanFocus)
+                        {
+                            SetFocus ();
+
+                            return true;
+                        }
+
+                        return false;
+                    });
     }
 
     /// <summary>
@@ -59,18 +59,17 @@ public partial class View // Command APIs
     /// </summary>
     /// <returns>
     ///     <see langword="null"/> if no event was raised; input processing should continue.
-    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should continue.
+    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should
+    ///     continue.
     ///     <see langword="true"/> if the event was raised and handled (or cancelled); input processing should stop.
     /// </returns>
     protected bool? RaiseCommandNotBound (ICommandContext? ctx)
     {
         CommandEventArgs args = new () { Context = ctx };
 
-        // Best practice is to invoke the virtual method first.
-        // This allows derived classes to handle the event and potentially cancel it.
         // For robustness' sake, even if the virtual method returns true, if the args 
         // indicate the event should be cancelled, we honor that.
-        if (OnCommandNotBound (args) || args.Cancel)
+        if (OnCommandNotBound (args) || args.Handled)
         {
             return true;
         }
@@ -78,13 +77,13 @@ public partial class View // Command APIs
         // If the event is not canceled by the virtual method, raise the event to notify any external subscribers.
         CommandNotBound?.Invoke (this, args);
 
-        return CommandNotBound is null ? null : args.Cancel;
+        return CommandNotBound is null ? null : args.Handled;
     }
 
     /// <summary>
-    ///      Called when a command that has not been bound is invoked.
-    ///     Set CommandEventArgs.Cancel to
-    ///     <see langword="true"/> and return <see langword="true"/> to cancel the event. The default implementation does nothing.
+    ///     Called when a command that has not been bound is invoked.
+    ///     Set CommandEventArgs.Handled to <see langword="true"/> and return <see langword="true"/> to indicate the event was
+    ///     handled and processing should stop.
     /// </summary>
     /// <param name="args">The event arguments.</param>
     /// <returns><see langword="true"/> to stop processing.</returns>
@@ -92,28 +91,35 @@ public partial class View // Command APIs
 
     /// <summary>
     ///     Cancelable event raised when a command that has not been bound is invoked.
+    ///     Set CommandEventArgs.Handled to <see langword="true"/> to indicate the event was handled and processing should
+    ///     stop.
     /// </summary>
     public event EventHandler<CommandEventArgs>? CommandNotBound;
 
     /// <summary>
-    ///     Called when the user is accepting the state of the View and the <see cref="Command.Accept"/> has been invoked. Calls <see cref="OnAccepting"/> which can be cancelled; if not cancelled raises <see cref="Accepting"/>.
+    ///     Called when the user is accepting the state of the View and the <see cref="Command.Accept"/> has been invoked.
+    ///     Calls <see cref="OnAccepting"/> which can be cancelled; if not cancelled raises <see cref="Accepting"/>.
     ///     event. The default <see cref="Command.Accept"/> handler calls this method.
     /// </summary>
     /// <remarks>
-    /// <para>
-    ///     The <see cref="Accepting"/> event should be 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>
+    ///     <para>
+    ///         The <see cref="Accepting"/> event should be 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>
     ///     <see langword="null"/> if no event was raised; input processing should continue.
-    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should continue.
+    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should
+    ///     continue.
     ///     <see langword="true"/> if the event was raised and handled (or cancelled); input processing should stop.
     /// </returns>
     protected bool? RaiseAccepting (ICommandContext? ctx)
@@ -124,9 +130,9 @@ public partial class View // Command APIs
         // Best practice is to invoke the virtual method first.
         // This allows derived classes to handle the event and potentially cancel it.
         Logging.Debug ($"{Title} ({ctx?.Source?.Title}) - Calling OnAccepting...");
-        args.Cancel = OnAccepting (args) || args.Cancel;
+        args.Handled = OnAccepting (args) || args.Handled;
 
-        if (!args.Cancel && Accepting is {})
+        if (!args.Handled && Accepting is { })
         {
             // If the event is not canceled by the virtual method, raise the event to notify any external subscribers.
             Logging.Debug ($"{Title} ({ctx?.Source?.Title}) - Raising Accepting...");
@@ -136,10 +142,10 @@ public partial class View // Command APIs
         // Accept is a special case where if the event is not canceled, the event is
         //  - Invoked on any peer-View with IsDefault == true
         //  - bubbled up the SuperView hierarchy.
-        if (!args.Cancel)
+        if (!args.Handled)
         {
             // If there's an IsDefault peer view in SubViews, try it
-            var isDefaultView = SuperView?.InternalSubViews.FirstOrDefault (v => v is Button { IsDefault: true });
+            View? isDefaultView = SuperView?.InternalSubViews.FirstOrDefault (v => v is Button { IsDefault: true });
 
             if (isDefaultView != this && isDefaultView is Button { IsDefault: true } button)
             {
@@ -147,7 +153,8 @@ public partial class View // Command APIs
                 // TODO: is generic?
 
                 Logging.Debug ($"{Title} ({ctx?.Source?.Title}) - InvokeCommand on Default View ({isDefaultView.Title})");
-                bool ? handled = isDefaultView.InvokeCommand (Command.Accept, ctx);
+                bool? handled = isDefaultView.InvokeCommand (Command.Accept, ctx);
+
                 if (handled == true)
                 {
                     return true;
@@ -157,47 +164,54 @@ public partial class View // Command APIs
             if (SuperView is { })
             {
                 Logging.Debug ($"{Title} ({ctx?.Source?.Title}) - Invoking Accept on SuperView ({SuperView.Title}/{SuperView.Id})...");
+
                 return SuperView?.InvokeCommand (Command.Accept, ctx);
             }
         }
 
-        return args.Cancel;
+        return args.Handled;
     }
 
     /// <summary>
-    ///     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.
+    ///     Called when the user is accepting the state of the View and the <see cref="Command.Accept"/> has been invoked.
+    ///     Set CommandEventArgs.Handled to <see langword="true"/> and return <see langword="true"/> to indicate the event was
+    ///     handled and processing should stop.
     /// </summary>
     /// <remarks>
-    /// <para>
-    ///    See <see cref="View.RaiseAccepting"/> for more information.
-    /// </para>
+    ///     <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; }
 
     /// <summary>
-    ///     Cancelable event raised when the user is accepting the state of the View and the <see cref="Command.Accept"/> has been invoked. Set
-    ///     CommandEventArgs.Cancel to cancel the event.
+    ///     Cancelable event raised when the user is accepting the state of the View and the <see cref="Command.Accept"/> has
+    ///     been invoked.
+    ///     Set CommandEventArgs.Handled to <see langword="true"/> to indicate the event was handled and processing should
+    ///     stop.
     /// </summary>
     /// <remarks>
-    /// <para>
-    ///    See <see cref="View.RaiseAccepting"/> for more information.
-    /// </para>
+    ///     <para>
+    ///         See <see cref="View.RaiseAccepting"/> for more information.
+    ///     </para>
     /// </remarks>
     public event EventHandler<CommandEventArgs>? Accepting;
 
     /// <summary>
-    ///     Called when the user has performed an action (e.g. <see cref="Command.Select"/>) causing the View to change state. Calls <see cref="OnSelecting"/> which can be cancelled; if not cancelled raises <see cref="Accepting"/>.
+    ///     Called when the user has performed an action (e.g. <see cref="Command.Select"/>) causing the View to change state.
+    ///     Calls <see cref="OnSelecting"/> which can be cancelled; if not cancelled raises <see cref="Accepting"/>.
     ///     event. The default <see cref="Command.Select"/> handler calls this method.
     /// </summary>
     /// <remarks>
-    ///     The <see cref="Selecting"/> event should be raised after the state of the View has been changed and before see <see cref="Accepting"/>.
+    ///     The <see cref="Selecting"/> event should be raised after the state of the View has been changed and before see
+    ///     <see cref="Accepting"/>.
     /// </remarks>
     /// <returns>
     ///     <see langword="null"/> if no event was raised; input processing should continue.
-    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should continue.
+    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should
+    ///     continue.
     ///     <see langword="true"/> if the event was raised and handled (or cancelled); input processing should stop.
     /// </returns>
     protected bool? RaiseSelecting (ICommandContext? ctx)
@@ -207,7 +221,7 @@ public partial class View // Command APIs
 
         // Best practice is to invoke the virtual method first.
         // This allows derived classes to handle the event and potentially cancel it.
-        if (OnSelecting (args) || args.Cancel)
+        if (OnSelecting (args) || args.Handled)
         {
             return true;
         }
@@ -215,41 +229,45 @@ public partial class View // Command APIs
         // If the event is not canceled by the virtual method, raise the event to notify any external subscribers.
         Selecting?.Invoke (this, args);
 
-        return Selecting is null ? null : args.Cancel;
+        return Selecting is null ? null : args.Handled;
     }
 
     /// <summary>
     ///     Called when the user has performed an action (e.g. <see cref="Command.Select"/>) causing the View to change state.
-    ///     Set CommandEventArgs.Cancel to
-    ///     <see langword="true"/> and return <see langword="true"/> to cancel the state change. The default implementation does nothing.
+    ///     Set CommandEventArgs.Handled to <see langword="true"/> and return <see langword="true"/> to indicate the event was
+    ///     handled and processing should stop.
     /// </summary>
     /// <param name="args">The event arguments.</param>
     /// <returns><see langword="true"/> to stop processing.</returns>
     protected virtual bool OnSelecting (CommandEventArgs args) { return false; }
 
     /// <summary>
-    ///     Cancelable event raised when the user has performed an action (e.g. <see cref="Command.Select"/>) causing the View to change state.
-    ///     CommandEventArgs.Cancel to <see langword="true"/> to cancel the state change.
+    ///     Cancelable event raised when the user has performed an action (e.g. <see cref="Command.Select"/>) causing the View
+    ///     to change state.
+    ///     Set CommandEventArgs.Handled to <see langword="true"/> to indicate the event was handled and processing should
+    ///     stop.
     /// </summary>
     public event EventHandler<CommandEventArgs>? Selecting;
 
     /// <summary>
-    ///     Called when the View is handling the user pressing the View's <see cref="HotKey"/>s. Calls <see cref="OnHandlingHotKey"/> which can be cancelled; if not cancelled raises <see cref="Accepting"/>.
+    ///     Called when the View is handling the user pressing the View's <see cref="HotKey"/>s. Calls
+    ///     <see cref="OnHandlingHotKey"/> which can be cancelled; if not cancelled raises <see cref="Accepting"/>.
     ///     event. The default <see cref="Command.HotKey"/> handler calls this method.
     /// </summary>
     /// <returns>
     ///     <see langword="null"/> if no event was raised; input processing should continue.
-    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should continue.
+    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should
+    ///     continue.
     ///     <see langword="true"/> if the event was raised and handled (or cancelled); input processing should stop.
     /// </returns>
     protected bool? RaiseHandlingHotKey ()
     {
-        CommandEventArgs args = new () { Context = new CommandContext<KeyBinding> () { Command = Command.HotKey } };
+        CommandEventArgs args = new () { Context = new CommandContext<KeyBinding> { Command = Command.HotKey } };
         Logging.Debug ($"{Title} ({args.Context?.Source?.Title})");
 
         // Best practice is to invoke the virtual method first.
         // This allows derived classes to handle the event and potentially cancel it.
-        if (OnHandlingHotKey (args) || args.Cancel)
+        if (OnHandlingHotKey (args) || args.Handled)
         {
             return true;
         }
@@ -257,12 +275,13 @@ public partial class View // Command APIs
         // If the event is not canceled by the virtual method, raise the event to notify any external subscribers.
         HandlingHotKey?.Invoke (this, args);
 
-        return HandlingHotKey is null ? null : args.Cancel;
+        return HandlingHotKey is null ? null : args.Handled;
     }
 
     /// <summary>
-    ///     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.
+    ///     Called when the View is handling the user pressing the View's <see cref="HotKey"/>.
+    ///     Set CommandEventArgs.Handled to <see langword="true"/> to indicate the event was handled and processing should
+    ///     stop.
     /// </summary>
     /// <param name="args"></param>
     /// <returns><see langword="true"/> to stop processing.</returns>
@@ -270,19 +289,20 @@ 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
-    ///     CommandEventArgs.Cancel to cancel the event.
+    ///     CommandEventArgs.Handled to <see langword="true"/> to indicate the event was handled and processing should stop.
     /// </summary>
     public event EventHandler<CommandEventArgs>? HandlingHotKey;
 
     #endregion Default Implementation
 
     /// <summary>
-    /// Function signature commands.
+    ///     Function signature commands.
     /// </summary>
     /// <param name="ctx">Provides context about the circumstances of invoking the command.</param>
     /// <returns>
     ///     <see langword="null"/> if no event was raised; input processing should continue.
-    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should continue.
+    ///     <see langword="false"/> if the event was raised and was not handled (or cancelled); input processing should
+    ///     continue.
     ///     <see langword="true"/> if the event was raised and handled (or cancelled); input processing should stop.
     /// </returns>
     public delegate bool? CommandImplementation (ICommandContext? ctx);
@@ -344,8 +364,10 @@ public partial class View // Command APIs
     /// <param name="binding">The binding that caused the invocation, if any. This will be passed as context with the command.</param>
     /// <returns>
     ///     <see langword="null"/> if no command was found; input processing should continue.
-    ///     <see langword="false"/> if the command was invoked and was not handled (or cancelled); input processing should continue.
-    ///     <see langword="true"/> if the command was invoked the command was handled (or cancelled); input processing should stop.
+    ///     <see langword="false"/> if the command was invoked and was not handled (or cancelled); input processing should
+    ///     continue.
+    ///     <see langword="true"/> if the command was invoked the command was handled (or cancelled); input processing should
+    ///     stop.
     /// </returns>
     public bool? InvokeCommands<TBindingType> (Command [] commands, TBindingType binding)
     {
@@ -359,7 +381,7 @@ public partial class View // Command APIs
             }
 
             // each command has its own return value
-            bool? thisReturn = InvokeCommand<TBindingType> (command, binding);
+            bool? thisReturn = InvokeCommand (command, binding);
 
             // if we haven't got anything yet, the current command result should be used
             toReturn ??= thisReturn;
@@ -375,14 +397,16 @@ public partial class View // Command APIs
     }
 
     /// <summary>
-    /// Invokes the specified command.
+    ///     Invokes the specified command.
     /// </summary>
     /// <param name="command">The command to invoke.</param>
     /// <param name="binding">The binding that caused the invocation, if any. This will be passed as context with the command.</param>
     /// <returns>
     ///     <see langword="null"/> if no command was found; input processing should continue.
-    ///     <see langword="false"/> if the command was invoked and was not handled (or cancelled); input processing should continue.
-    ///     <see langword="true"/> if the command was invoked the command was handled (or cancelled); input processing should stop.
+    ///     <see langword="false"/> if the command was invoked and was not handled (or cancelled); input processing should
+    ///     continue.
+    ///     <see langword="true"/> if the command was invoked the command was handled (or cancelled); input processing should
+    ///     stop.
     /// </returns>
     public bool? InvokeCommand<TBindingType> (Command command, TBindingType binding)
     {
@@ -390,24 +414,27 @@ public partial class View // Command APIs
         {
             _commandImplementations.TryGetValue (Command.NotBound, out implementation);
         }
-        return implementation! (new CommandContext<TBindingType> ()
-        {
-            Command = command,
-            Source = this,
-            Binding = binding,
-        });
-    }
 
+        return implementation! (
+                                new CommandContext<TBindingType>
+                                {
+                                    Command = command,
+                                    Source = this,
+                                    Binding = binding
+                                });
+    }
 
     /// <summary>
-    /// Invokes the specified command.
+    ///     Invokes the specified command.
     /// </summary>
     /// <param name="command">The command to invoke.</param>
     /// <param name="ctx">The context to pass with the command.</param>
     /// <returns>
     ///     <see langword="null"/> if no command was found; input processing should continue.
-    ///     <see langword="false"/> if the command was invoked and was not handled (or cancelled); input processing should continue.
-    ///     <see langword="true"/> if the command was invoked the command was handled (or cancelled); input processing should stop.
+    ///     <see langword="false"/> if the command was invoked and was not handled (or cancelled); input processing should
+    ///     continue.
+    ///     <see langword="true"/> if the command was invoked the command was handled (or cancelled); input processing should
+    ///     stop.
     /// </returns>
     public bool? InvokeCommand (Command command, ICommandContext? ctx)
     {
@@ -415,17 +442,20 @@ public partial class View // Command APIs
         {
             _commandImplementations.TryGetValue (Command.NotBound, out implementation);
         }
+
         return implementation! (ctx);
     }
 
     /// <summary>
-    /// Invokes the specified command without context.
+    ///     Invokes the specified command without context.
     /// </summary>
     /// <param name="command">The command to invoke.</param>
     /// <returns>
     ///     <see langword="null"/> if no command was found; input processing should continue.
-    ///     <see langword="false"/> if the command was invoked and was not handled (or cancelled); input processing should continue.
-    ///     <see langword="true"/> if the command was invoked the command was handled (or cancelled); input processing should stop.
+    ///     <see langword="false"/> if the command was invoked and was not handled (or cancelled); input processing should
+    ///     continue.
+    ///     <see langword="true"/> if the command was invoked the command was handled (or cancelled); input processing should
+    ///     stop.
     /// </returns>
     public bool? InvokeCommand (Command command)
     {
@@ -434,12 +464,12 @@ public partial class View // Command APIs
             _commandImplementations.TryGetValue (Command.NotBound, out implementation);
         }
 
-        return implementation! (new CommandContext<object> ()
-        {
-            Command = command,
-            Source = this,
-            Binding = null,
-        });
-
+        return implementation! (
+                                new CommandContext<object>
+                                {
+                                    Command = command,
+                                    Source = this,
+                                    Binding = null
+                                });
     }
 }

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

@@ -180,7 +180,7 @@ public class CheckBox : View
     /// <summary>Called when the <see cref="CheckBox"/> state is changing.</summary>
     /// <remarks>
     ///     <para>
-    ///         The state cahnge can be cancelled by setting the args.Cancel to <see langword="true"/>.
+    ///         The state change can be cancelled by setting the args.Cancel to <see langword="true"/>.
     ///     </para>
     /// </remarks>
     protected virtual bool OnCheckedStateChanging (CancelEventArgs<CheckState> args) { return false; }

+ 2 - 2
Terminal.Gui/Views/ColorPicker.Prompt.cs

@@ -36,7 +36,7 @@ public partial class ColorPicker
         btnOk.Accepting += (s, e) =>
                         {
                             accept = true;
-                            e.Cancel = true;
+                            e.Handled = true;
                             Application.RequestStop ();
                         };
 
@@ -50,7 +50,7 @@ public partial class ColorPicker
 
         btnCancel.Accepting += (s, e) =>
                             {
-                                e.Cancel = true;
+                                e.Handled = true;
                                 Application.RequestStop ();
                             };
 

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

@@ -39,7 +39,7 @@ public class ComboBox : View, IDesignable
         _listview.Accepting += (sender, args) =>
                               {
                                   // This prevents Accepted from bubbling up to the combobox
-                                  args.Cancel = true;
+                                  args.Handled = true;
 
                                   // But OpenSelectedItem won't be fired because of that. So do it here.
                                   SelectText ();

+ 7 - 7
Terminal.Gui/Views/FileDialog.cs

@@ -83,7 +83,7 @@ public class FileDialog : Dialog, IDesignable
 
         _btnOk.Accepting += (s, e) =>
                             {
-                                if (e.Cancel)
+                                if (e.Handled)
                                 {
                                     return;
                                 }
@@ -100,12 +100,12 @@ public class FileDialog : Dialog, IDesignable
 
         _btnCancel.Accepting += (s, e) =>
                                 {
-                                    if (e.Cancel)
+                                    if (e.Handled)
                                     {
                                         return;
                                     }
 
-                                    e.Cancel = true;
+                                    e.Handled = true;
 
                                     if (Modal)
                                     {
@@ -118,7 +118,7 @@ public class FileDialog : Dialog, IDesignable
         _btnUp.Accepting += (s, e) =>
                             {
                                 _history.Up ();
-                                e.Cancel = true;
+                                e.Handled = true;
                             };
 
         _btnBack = new() { X = Pos.Right (_btnUp) + 1, Y = 1, NoPadding = true };
@@ -126,7 +126,7 @@ public class FileDialog : Dialog, IDesignable
         _btnBack.Accepting += (s, e) =>
                               {
                                   _history.Back ();
-                                  e.Cancel = true;
+                                  e.Handled = true;
                               };
 
         _btnForward = new() { X = Pos.Right (_btnBack) + 1, Y = 1, NoPadding = true };
@@ -134,7 +134,7 @@ public class FileDialog : Dialog, IDesignable
         _btnForward.Accepting += (s, e) =>
                                  {
                                      _history.Forward();
-                                     e.Cancel = true;
+                                     e.Handled = true;
                                  };
 
         _tbPath = new() { Width = Dim.Fill (), CaptionColor = new (Color.Black) };
@@ -216,7 +216,7 @@ public class FileDialog : Dialog, IDesignable
         _btnToggleSplitterCollapse.Accepting += (s, e) =>
                                                 {
                                                     // Required otherwise the Save button clicks itself
-                                                    e.Cancel = true;
+                                                    e.Handled = true;
                                                     Tile tile = _splitContainer.Tiles.ElementAt (0);
 
                                                     bool newState = !tile.ContentView.Visible;

+ 2 - 2
Terminal.Gui/Views/FlagSelector.cs

@@ -370,14 +370,14 @@ public class FlagSelector : View, IOrientation, IDesignable
                               {
                                   if (RaiseSelecting (args.Context) is true)
                                   {
-                                      args.Cancel = true;
+                                      args.Handled = true;
 
                                       return;
                                   };
 
                                   if (RaiseAccepting (args.Context) is true)
                                   {
-                                      args.Cancel = true;
+                                      args.Handled = true;
                                   }
                               };
 

+ 4 - 4
Terminal.Gui/Views/Menu/PopoverMenu.cs

@@ -490,8 +490,8 @@ public class PopoverMenu : PopoverBaseImpl, IDesignable
         {
             if (keyCommandContext.Binding.Key is { } && keyCommandContext.Binding.Key == Application.QuitKey && SuperView is { Visible: true })
             {
-                Logging.Debug ($"{Title} - Setting e.Cancel = true - Application.QuitKey/Command = Command.Quit");
-                e.Cancel = true;
+                Logging.Debug ($"{Title} - Setting e.Handled = true - Application.QuitKey/Command = Command.Quit");
+                e.Handled = true;
             }
         }
     }
@@ -533,9 +533,9 @@ public class PopoverMenu : PopoverBaseImpl, IDesignable
         Logging.Debug ($"{Title} - calling base.OnAccepting: {args.Context?.Command}");
         bool? ret = base.OnAccepting (args);
 
-        if (ret is true || args.Cancel)
+        if (ret is true || args.Handled)
         {
-            return args.Cancel = true;
+            return args.Handled = true;
         }
 
         // Only raise Accepted if the command came from one of our MenuItems

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

@@ -371,7 +371,7 @@ public static class MessageBox
 
                                        if (e is { })
                                        {
-                                           e.Cancel = true;
+                                           e.Handled = true;
                                        }
 
                                        Application.RequestStop ();

+ 3 - 3
Terminal.Gui/Views/NumericUpDown.cs

@@ -148,13 +148,13 @@ public class NumericUpDown<T> : View where T : notnull
         void OnDownButtonOnAccept (object? s, CommandEventArgs e)
         {
             InvokeCommand (Command.Down);
-            e.Cancel = true;
+            e.Handled = true;
         }
 
         void OnUpButtonOnAccept (object? s, CommandEventArgs e)
         {
             InvokeCommand (Command.Up);
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 
@@ -167,7 +167,7 @@ public class NumericUpDown<T> : View where T : notnull
     ///     <para>
     ///         <see cref="ValueChanging"/> and <see cref="ValueChanged"/> events are raised when the value changes.
     ///         The <see cref="ValueChanging"/> event can be canceled the change setting
-    ///         <see cref="CancelEventArgs{T}"/><c>.Cancel</c> to <see langword="true"/>.
+    ///         <see cref="HandledEventArgs"/><c>.Handled</c> to <see langword="true"/>.
     ///     </para>
     /// </remarks>
     public T Value

+ 2 - 2
Terminal.Gui/Views/OptionSelector.cs

@@ -228,7 +228,7 @@ public class OptionSelector : View, IOrientation, IDesignable
         {
             if (RaiseSelecting (args.Context) is true)
             {
-                args.Cancel = true;
+                args.Handled = true;
 
                 return;
             }
@@ -236,7 +236,7 @@ public class OptionSelector : View, IOrientation, IDesignable
 
             if (RaiseAccepting (args.Context) is true)
             {
-                args.Cancel = true;
+                args.Handled = true;
             }
         };
 

+ 2 - 2
Terminal.Gui/Views/ScrollBar/ScrollBar.cs

@@ -87,13 +87,13 @@ public class ScrollBar : View, IOrientation, IDesignable
         void OnDecreaseButtonOnAccept (object? s, CommandEventArgs e)
         {
             Position -= Increment;
-            e.Cancel = true;
+            e.Handled = true;
         }
 
         void OnIncreaseButtonOnAccept (object? s, CommandEventArgs e)
         {
             Position += Increment;
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 

+ 2 - 2
Terminal.Gui/Views/Shortcut.cs

@@ -450,7 +450,7 @@ public class Shortcut : View, IOrientation, IDesignable
             void CommandViewOnAccepted (object? sender, CommandEventArgs e)
             {
                 // Always eat CommandView.Accept
-                e.Cancel = true;
+                e.Handled = true;
             }
 
             void CommandViewOnSelecting (object? sender, CommandEventArgs e)
@@ -462,7 +462,7 @@ public class Shortcut : View, IOrientation, IDesignable
                     InvokeCommand<KeyBinding> (Command.Select, new ([Command.Select], null, this));
                 }
 
-                e.Cancel = true;
+                e.Handled = true;
             }
         }
     }

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

@@ -140,7 +140,7 @@ public class StatusBar : Bar, IDesignable
                            {
                                button1.Visible = !button1.Visible;
                                button1.Enabled = button1.Visible;
-                               e.Cancel = false;
+                               e.Handled = false;
                            };
 
         Add (new Label

+ 3 - 3
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -453,7 +453,7 @@ public class Wizard : Dialog
 
         if (!args.Cancel)
         {
-            e.Cancel = GoBack ();
+            e.Handled = GoBack ();
         }
     }
 
@@ -471,7 +471,7 @@ public class Wizard : Dialog
                 if (IsCurrentTop)
                 {
                     Application.RequestStop (this);
-                    e.Cancel = true;
+                    e.Handled = true;
                 }
 
                 // Wizard was created as a non-modal (just added to another View). 
@@ -485,7 +485,7 @@ public class Wizard : Dialog
 
             if (!args.Cancel)
             {
-                e.Cancel = GoNext ();
+                e.Handled = GoNext ();
             }
         }
     }

+ 4 - 4
Tests/UnitTests/View/ViewCommandTests.cs

@@ -28,7 +28,7 @@ public class ViewCommandTests
         btnA.Accepting += (s, e) =>
                           {
                               aAcceptedCount++;
-                              e.Cancel = aCancelAccepting;
+                              e.Handled = aCancelAccepting;
                           };
 
         var btnB = new Button ()
@@ -40,7 +40,7 @@ public class ViewCommandTests
         btnB.Accepting += (s, e) =>
                           {
                               bAcceptedCount++;
-                              e.Cancel = bCancelAccepting;
+                              e.Handled = bCancelAccepting;
                           };
         w.Add (btnA, btnB);
 
@@ -96,7 +96,7 @@ public class ViewCommandTests
         w.Accepting += (s, e) =>
                        {
                            wAcceptedCount++;
-                           e.Cancel = wCancelAccepting;
+                           e.Handled = wCancelAccepting;
                        };
 
         int btnAcceptedCount = 0;
@@ -112,7 +112,7 @@ public class ViewCommandTests
         btn.Accepting += (s, e) =>
                          {
                              btnAcceptedCount++;
-                             e.Cancel = btnCancelAccepting;
+                             e.Handled = btnCancelAccepting;
                          };
 
         w.Add (btn);

+ 4 - 4
Tests/UnitTests/Views/ButtonTests.cs

@@ -513,7 +513,7 @@ public class ButtonTests (ITestOutputHelper output)
         void ButtonAccept (object sender, CommandEventArgs e)
         {
             acceptInvoked = true;
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 
@@ -616,7 +616,7 @@ public class ButtonTests (ITestOutputHelper output)
         button.Accepting += (s, e) =>
                             {
                                 acceptedCount++;
-                                e.Cancel = true;
+                                e.Handled = true;
                             };
 
         me = new ();
@@ -661,7 +661,7 @@ public class ButtonTests (ITestOutputHelper output)
         button.Accepting += (s, e) =>
                             {
                                 acceptedCount++;
-                                e.Cancel = true;
+                                e.Handled = true;
                             };
 
         var selectingCount = 0;
@@ -669,7 +669,7 @@ public class ButtonTests (ITestOutputHelper output)
         button.Selecting += (s, e) =>
                             {
                                 selectingCount++;
-                                e.Cancel = true;
+                                e.Handled = true;
                             };
 
         me.Flags = pressed;

+ 3 - 3
Tests/UnitTests/Views/CheckBoxTests.cs

@@ -246,7 +246,7 @@ public class CheckBoxTests (ITestOutputHelper output)
         void ViewOnAccept (object sender, CommandEventArgs e)
         {
             acceptInvoked = true;
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 
@@ -313,7 +313,7 @@ public class CheckBoxTests (ITestOutputHelper output)
         checkBox.Accepting += (s, e) =>
                               {
                                   acceptCount++;
-                                  e.Cancel = true;
+                                  e.Handled = true;
                               };
 
         checkBox.HasFocus = true;
@@ -596,7 +596,7 @@ public class CheckBoxTests (ITestOutputHelper output)
         void OnSelecting (object sender, CommandEventArgs e)
         {
             checkedInvoked = true;
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 

+ 1 - 1
Tests/UnitTests/Views/ListViewTests.cs

@@ -488,7 +488,7 @@ Item 6",
         void Accepted (object sender, CommandEventArgs e)
         {
             accepted = true;
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 

+ 2 - 2
Tests/UnitTests/Views/RadioGroupTests.cs

@@ -689,7 +689,7 @@ public class RadioGroupTests (ITestOutputHelper output)
         radioGroup.Accepting += (s, e) =>
                              {
                                  acceptedCount++;
-                                 e.Cancel = handleAccepted;
+                                 e.Handled = handleAccepted;
                              };
 
         Assert.True (radioGroup.DoubleClickAccepts);
@@ -742,7 +742,7 @@ public class RadioGroupTests (ITestOutputHelper output)
         superView.Accepting += (s, a) =>
                             {
                                 superViewAcceptCount++;
-                                a.Cancel = true;
+                                a.Handled = true;
                             };
 
         Assert.Equal (0, superViewAcceptCount);

+ 3 - 3
Tests/UnitTests/Views/ShortcutTests.cs

@@ -205,7 +205,7 @@ public class ShortcutTests
         var checkboxSelected = 0;
         shortcut.CommandView.Selecting += (s, e) =>
                                          {
-                                             if (e.Cancel)
+                                             if (e.Handled)
                                              {
                                                  return;
                                              }
@@ -226,7 +226,7 @@ public class ShortcutTests
         shortcut.Accepting += (s, e) =>
                              {
                                  accepted++;
-                                 e.Cancel = true;
+                                 e.Handled = true;
                              };
 
         Application.RaiseMouseEvent (
@@ -326,7 +326,7 @@ public class ShortcutTests
         shortcut.Accepting += (s, e) =>
                              {
                                  accepted++;
-                                 e.Cancel = true;
+                                 e.Handled = true;
                              };
 
         var selected = 0;

+ 1 - 1
Tests/UnitTests/Views/TextFieldTests.cs

@@ -765,7 +765,7 @@ public class TextFieldTests (ITestOutputHelper output)
         void TextFieldAccept (object sender, CommandEventArgs e)
         {
             textFieldAccept++;
-            e.Cancel = handleAccept;
+            e.Handled = handleAccept;
         }
 
         void ButtonAccept (object sender, CommandEventArgs e) { buttonAccept++; }

+ 1 - 1
Tests/UnitTests/Views/TextViewTests.cs

@@ -8687,7 +8687,7 @@ line.
         void TextViewAccept (object sender, CommandEventArgs e)
         {
             textViewAccept++;
-            e.Cancel = handleAccept;
+            e.Handled = handleAccept;
         }
 
         void ButtonAccept (object sender, CommandEventArgs e) { buttonAccept++; }

+ 1 - 1
Tests/UnitTests/Views/TreeViewTests.cs

@@ -1425,7 +1425,7 @@ oot two
         void Accept (object sender, CommandEventArgs e)
         {
             accepted = true;
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 }

+ 6 - 6
Tests/UnitTestsParallelizable/View/ViewCommandTests.cs

@@ -49,7 +49,7 @@ public class ViewCommandTests
         void ViewOnAccept (object sender, CommandEventArgs e)
         {
             acceptInvoked = true;
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 
@@ -180,7 +180,7 @@ public class ViewCommandTests
         void ViewOnSelect (object sender, CommandEventArgs e)
         {
             selectingInvoked = true;
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 
@@ -276,25 +276,25 @@ public class ViewCommandTests
 
             Accepting += (s, a) =>
                          {
-                             a.Cancel = HandleAccepted;
+                             a.Handled = HandleAccepted;
                              AcceptedCount++;
                          };
 
             HandlingHotKey += (s, a) =>
                               {
-                                  a.Cancel = HandleHandlingHotKey;
+                                  a.Handled = HandleHandlingHotKey;
                                   HandlingHotKeyCount++;
                               };
 
             Selecting += (s, a) =>
                          {
-                             a.Cancel = HandleSelecting;
+                             a.Handled = HandleSelecting;
                              SelectingCount++;
                          };
 
             CommandNotBound += (s, a) =>
                                {
-                                   a.Cancel = HandleCommandNotBound;
+                                   a.Handled = HandleCommandNotBound;
                                    CommandNotBoundCount++;
                                };
         }

+ 1 - 1
Tests/UnitTestsParallelizable/Views/TextFieldTests.cs

@@ -200,7 +200,7 @@ public class TextFieldTests
         void TextViewAccept (object sender, CommandEventArgs e)
         {
             tfAcceptedInvoked = true;
-            e.Cancel = handle;
+            e.Handled = handle;
         }
     }