diff --git a/Examples/CommunityToolkitExample/LoginView.cs b/Examples/CommunityToolkitExample/LoginView.cs index 2e72b45cf4..a1ead6c33b 100644 --- a/Examples/CommunityToolkitExample/LoginView.cs +++ b/Examples/CommunityToolkitExample/LoginView.cs @@ -23,15 +23,15 @@ public LoginView (LoginViewModel viewModel) { 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 (); }; diff --git a/Examples/Example/Example.cs b/Examples/Example/Example.cs index e260230c58..80d3de35de 100644 --- a/Examples/Example/Example.cs +++ b/Examples/Example/Example.cs @@ -78,8 +78,8 @@ public ExampleWindow () { 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 diff --git a/Examples/NativeAot/Program.cs b/Examples/NativeAot/Program.cs index d186e33a5c..87bc2ae610 100644 --- a/Examples/NativeAot/Program.cs +++ b/Examples/NativeAot/Program.cs @@ -105,8 +105,8 @@ public ExampleWindow () { 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 diff --git a/Examples/ReactiveExample/LoginViewModel.cs b/Examples/ReactiveExample/LoginViewModel.cs index 60dcfc90d2..2c2f98a53f 100644 --- a/Examples/ReactiveExample/LoginViewModel.cs +++ b/Examples/ReactiveExample/LoginViewModel.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using ReactiveUI; using ReactiveUI.SourceGenerators; +using Terminal.Gui; namespace ReactiveExample; @@ -50,7 +51,7 @@ public LoginViewModel () _isValidHelper = canLogin.ToProperty (this, x => x.IsValid); - Login = ReactiveCommand.CreateFromTask + Login = ReactiveCommand.CreateFromTask ( e => Task.Delay (TimeSpan.FromSeconds (1)), canLogin @@ -76,8 +77,8 @@ public LoginViewModel () } [ReactiveCommand] - public void Clear (HandledEventArgs args) { } + public void Clear (CommandEventArgs args) { } [IgnoreDataMember] - public ReactiveCommand Login { get; } + public ReactiveCommand Login { get; } } diff --git a/Examples/SelfContained/Program.cs b/Examples/SelfContained/Program.cs index 886fd334b9..2e65c2e541 100644 --- a/Examples/SelfContained/Program.cs +++ b/Examples/SelfContained/Program.cs @@ -104,8 +104,8 @@ public ExampleWindow () { 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 diff --git a/Examples/UICatalog/Scenarios/Adornments.cs b/Examples/UICatalog/Scenarios/Adornments.cs index f2e664f9c7..86dce6f4b2 100644 --- a/Examples/UICatalog/Scenarios/Adornments.cs +++ b/Examples/UICatalog/Scenarios/Adornments.cs @@ -143,7 +143,7 @@ public override void Main () 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"); diff --git a/Examples/UICatalog/Scenarios/AllViewsTester.cs b/Examples/UICatalog/Scenarios/AllViewsTester.cs index 8bc3f0c420..67a049acd3 100644 --- a/Examples/UICatalog/Scenarios/AllViewsTester.cs +++ b/Examples/UICatalog/Scenarios/AllViewsTester.cs @@ -83,7 +83,7 @@ public override void Main () _classListView.Accepting += (sender, args) => { _curView?.SetFocus (); - args.Cancel = true; + args.Handled = true; }; _adornmentsEditor = new () diff --git a/Examples/UICatalog/Scenarios/Bars.cs b/Examples/UICatalog/Scenarios/Bars.cs index 444c8e89f4..952436a585 100644 --- a/Examples/UICatalog/Scenarios/Bars.cs +++ b/Examples/UICatalog/Scenarios/Bars.cs @@ -486,7 +486,7 @@ private void ConfigureMenu (Bar bar) 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 void ConfigStatusBar (Bar bar) { button1.Visible = !button1.Visible; button1.Enabled = button1.Visible; - e.Cancel = false; + e.Handled = true; }; bar.Add (new Label diff --git a/Examples/UICatalog/Scenarios/Buttons.cs b/Examples/UICatalog/Scenarios/Buttons.cs index 4cafab5be2..6b1051e22e 100644 --- a/Examples/UICatalog/Scenarios/Buttons.cs +++ b/Examples/UICatalog/Scenarios/Buttons.cs @@ -49,16 +49,16 @@ public override void Main () 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 @@ static void DoMessage (Button button, string txt) { string btnText = button.Text; MessageBox.Query ("Message", $"Did you click {txt}?", "Yes", "No"); - e.Cancel = true; + e.Handled = true; }; } @@ -114,7 +114,7 @@ static void DoMessage (Button button, string txt) 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 @@ static void DoMessage (Button button, string txt) textChanger.Accepting += (s, e) => { textChanger.Text += "!"; - e.Cancel = true; + e.Handled = true; }; main.Add ( @@ -133,7 +133,7 @@ static void DoMessage (Button button, string txt) 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 @@ static void DoMessage (Button button, string txt) removeButton.Accepting += (s, e) => { removeButton.Visible = false; - e.Cancel = true; + e.Handled = true; }; var computedFrame = new FrameView @@ -172,7 +172,7 @@ static void DoMessage (Button button, string txt) moveBtn.Accepting += (s, e) => { moveBtn.X = moveBtn.Frame.X + 5; - e.Cancel = true; + e.Handled = true; }; computedFrame.Add (moveBtn); @@ -189,7 +189,7 @@ static void DoMessage (Button button, string txt) sizeBtn.Accepting += (s, e) => { sizeBtn.Width = sizeBtn.Frame.Width + 5; - e.Cancel = true; + e.Handled = true; }; computedFrame.Add (sizeBtn); @@ -214,7 +214,7 @@ static void DoMessage (Button button, string txt) moveBtnA.Frame.Width, moveBtnA.Frame.Height ); - e.Cancel = true; + e.Handled = true; }; absoluteFrame.Add (moveBtnA); @@ -232,7 +232,7 @@ static void DoMessage (Button button, string txt) sizeBtnA.Frame.Width + 5, sizeBtnA.Frame.Height ); - e.Cancel = true; + e.Handled = true; }; absoluteFrame.Add (sizeBtnA); @@ -300,7 +300,7 @@ string MoveHotkey (string txt) moveHotKeyBtn.Accepting += (s, e) => { moveHotKeyBtn.Text = MoveHotkey (moveHotKeyBtn.Text); - e.Cancel = true; + e.Handled = true; }; main.Add (moveHotKeyBtn); @@ -317,7 +317,7 @@ string MoveHotkey (string txt) moveUnicodeHotKeyBtn.Accepting += (s, e) => { moveUnicodeHotKeyBtn.Text = MoveHotkey (moveUnicodeHotKeyBtn.Text); - e.Cancel = true; + e.Handled = true; }; main.Add (moveUnicodeHotKeyBtn); @@ -401,7 +401,7 @@ void NumericUpDown_ValueChanged (object sender, EventArgs e) { } noRepeatButton.Accepting += (s, e) => { noRepeatButton.Title = $"Accept Cou_nt: {++noRepeatAcceptCount}"; - e.Cancel = true; + e.Handled = true; }; main.Add (label, noRepeatButton); @@ -423,7 +423,7 @@ void NumericUpDown_ValueChanged (object sender, EventArgs e) { } repeatButton.Accepting += (s, e) => { repeatButton.Title = $"Accept Co_unt: {++acceptCount}"; - e.Cancel = true; + e.Handled = true; }; var enableCB = new CheckBox diff --git a/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs b/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs index 60bdb954f7..38bf735bdc 100644 --- a/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs +++ b/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs @@ -256,7 +256,7 @@ void JumpEditOnAccept (object? sender, CommandEventArgs e) _charMap.SetFocus (); // Cancel the event to prevent ENTER from being handled elsewhere - e.Cancel = true; + e.Handled = true; } } diff --git a/Examples/UICatalog/Scenarios/Dialogs.cs b/Examples/UICatalog/Scenarios/Dialogs.cs index 7e39c3aa6b..62203962b4 100644 --- a/Examples/UICatalog/Scenarios/Dialogs.cs +++ b/Examples/UICatalog/Scenarios/Dialogs.cs @@ -198,7 +198,7 @@ public override void Main () ); Application.Run (dlg); dlg.Dispose (); - e.Cancel = true; + e.Handled = true; }; app.Add (showDialogButton); @@ -258,7 +258,7 @@ Label buttonPressedLabel button.Accepting += (s, e) => { clicked = buttonId; - e.Cancel = true; + e.Handled = true; Application.RequestStop (); }; buttons.Add (button); @@ -313,7 +313,7 @@ Label buttonPressedLabel { clicked = buttonId; Application.RequestStop (); - e.Cancel = true; + e.Handled = true; }; buttons.Add (button); dialog.AddButton (button); @@ -322,7 +322,7 @@ Label buttonPressedLabel //{ // button.TabIndex = buttons [buttons.Count - 2].TabIndex + 1; //} - e.Cancel = true; + e.Handled = true; }; dialog.Add (add); @@ -340,7 +340,7 @@ Label buttonPressedLabel button.Text += char.ConvertFromUtf32 (CODE_POINT); } - e.Cancel = true; + e.Handled = true; }; dialog.Add (addChar); diff --git a/Examples/UICatalog/Scenarios/Editors/DimEditor.cs b/Examples/UICatalog/Scenarios/Editors/DimEditor.cs index 3e0a07d14d..cbb0390f49 100644 --- a/Examples/UICatalog/Scenarios/Editors/DimEditor.cs +++ b/Examples/UICatalog/Scenarios/Editors/DimEditor.cs @@ -114,7 +114,7 @@ private void DimEditor_Initialized (object? sender, EventArgs e) { // ignored } - args.Cancel = true; + args.Handled = true; }; Add (_valueEdit); diff --git a/Examples/UICatalog/Scenarios/Editors/PosEditor.cs b/Examples/UICatalog/Scenarios/Editors/PosEditor.cs index 2df3f78eac..f6a05f7112 100644 --- a/Examples/UICatalog/Scenarios/Editors/PosEditor.cs +++ b/Examples/UICatalog/Scenarios/Editors/PosEditor.cs @@ -115,7 +115,7 @@ private void PosEditor_Initialized (object? sender, EventArgs e) // ignored } - args.Cancel = true; + args.Handled = true; }; Add (_valueEdit); diff --git a/Examples/UICatalog/Scenarios/FileDialogExamples.cs b/Examples/UICatalog/Scenarios/FileDialogExamples.cs index 646989b309..d5267a4284 100644 --- a/Examples/UICatalog/Scenarios/FileDialogExamples.cs +++ b/Examples/UICatalog/Scenarios/FileDialogExamples.cs @@ -141,7 +141,7 @@ public override void Main () } finally { - e.Cancel = true; + e.Handled = true; } }; win.Add (btn); diff --git a/Examples/UICatalog/Scenarios/Generic.cs b/Examples/UICatalog/Scenarios/Generic.cs index 2129402dc9..be11ce4bf4 100644 --- a/Examples/UICatalog/Scenarios/Generic.cs +++ b/Examples/UICatalog/Scenarios/Generic.cs @@ -39,8 +39,8 @@ public override void Main () 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"); }; diff --git a/Examples/UICatalog/Scenarios/LineDrawing.cs b/Examples/UICatalog/Scenarios/LineDrawing.cs index bb4ebb0a4c..52da1a684c 100644 --- a/Examples/UICatalog/Scenarios/LineDrawing.cs +++ b/Examples/UICatalog/Scenarios/LineDrawing.cs @@ -153,7 +153,7 @@ public static bool PromptForColor (string title, Color current, out Color newCol btnOk.Accepting += (s, e) => { accept = true; - e.Cancel = true; + e.Handled = true; Application.RequestStop (); }; @@ -167,7 +167,7 @@ public static bool PromptForColor (string title, Color current, out Color newCol btnCancel.Accepting += (s, e) => { - e.Cancel = true; + e.Handled = true; Application.RequestStop (); }; diff --git a/Examples/UICatalog/Scenarios/Menus.cs b/Examples/UICatalog/Scenarios/Menus.cs index 6036f8177f..f8d3b2fdc6 100644 --- a/Examples/UICatalog/Scenarios/Menus.cs +++ b/Examples/UICatalog/Scenarios/Menus.cs @@ -53,7 +53,7 @@ public override void Main () 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 override void Main () 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 override void Main () 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 MenuHost () 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 MenuHost () 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 MenuHost () openBtn.Accepting += (s, e) => { - e.Cancel = true; + e.Handled = true; Logging.Trace ($"openBtn.Accepting - Sending F9. {e.Context?.Source?.Title}"); NewKeyDownEvent (menuBar.Key); }; diff --git a/Examples/UICatalog/Scenarios/MessageBoxes.cs b/Examples/UICatalog/Scenarios/MessageBoxes.cs index 934a700709..fedb818d7b 100644 --- a/Examples/UICatalog/Scenarios/MessageBoxes.cs +++ b/Examples/UICatalog/Scenarios/MessageBoxes.cs @@ -279,7 +279,7 @@ public override void Main () buttonPressedLabel.Text = "Invalid Options"; } - e.Cancel = true; + e.Handled = true; }; app.Add (showMessageBoxButton); diff --git a/Examples/UICatalog/Scenarios/Shortcuts.cs b/Examples/UICatalog/Scenarios/Shortcuts.cs index 4eb9cea94b..06bde96ac7 100644 --- a/Examples/UICatalog/Scenarios/Shortcuts.cs +++ b/Examples/UICatalog/Scenarios/Shortcuts.cs @@ -426,7 +426,7 @@ private void App_Loaded (object? sender, EventArgs e) return; } bgColor.SelectedColor++; - args.Cancel = true; + args.Handled = true; }; bgColor.ColorChanged += (o, args) => @@ -467,7 +467,7 @@ private void App_Loaded (object? sender, EventArgs e) { shortcut.Selecting += (o, args) => { - if (args.Cancel) + if (args.Handled) { return; } @@ -477,13 +477,13 @@ private void App_Loaded (object? sender, EventArgs e) 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 @@ private void App_Loaded (object? sender, EventArgs e) 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 @@ private void App_Loaded (object? sender, EventArgs e) 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"); } diff --git a/Examples/UICatalog/Scenarios/SimpleDialog.cs b/Examples/UICatalog/Scenarios/SimpleDialog.cs index cf3a60a8cd..f9bb198d73 100644 --- a/Examples/UICatalog/Scenarios/SimpleDialog.cs +++ b/Examples/UICatalog/Scenarios/SimpleDialog.cs @@ -44,7 +44,7 @@ public override void Main () button.Accepting += (s, e) => { Application.Run (dialog); - e.Cancel = true; + e.Handled = true; }; appWindow.Add (button); diff --git a/Examples/UICatalog/Scenarios/Sliders.cs b/Examples/UICatalog/Scenarios/Sliders.cs index c2c30588ee..5dc1d212f6 100644 --- a/Examples/UICatalog/Scenarios/Sliders.cs +++ b/Examples/UICatalog/Scenarios/Sliders.cs @@ -591,7 +591,7 @@ public override void Main () { eventSource.Add ($"Accept: {string.Join(",", slider.GetSetOptions ())}"); eventLog.MoveDown (); - args.Cancel = true; + args.Handled = true; }; slider.OptionsChanged += (o, args) => { diff --git a/Examples/UICatalog/Scenarios/Text.cs b/Examples/UICatalog/Scenarios/Text.cs index eafae77eb6..541aec2add 100644 --- a/Examples/UICatalog/Scenarios/Text.cs +++ b/Examples/UICatalog/Scenarios/Text.cs @@ -452,7 +452,7 @@ void TextView_DrawContent (object sender, DrawEventArgs e) 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}"; diff --git a/Examples/UICatalog/UICatalogTop.cs b/Examples/UICatalog/UICatalogTop.cs index 27c544a5bd..c5fc081338 100644 --- a/Examples/UICatalog/UICatalogTop.cs +++ b/Examples/UICatalog/UICatalogTop.cs @@ -611,7 +611,7 @@ private StatusBar CreateStatusBar () statusBarShortcut.Accepting += (sender, args) => { statusBar.Visible = !_statusBar!.Visible; - args.Cancel = true; + args.Handled = true; }; _force16ColorsShortcutCb = new () diff --git a/Terminal.Gui/FileServices/DefaultFileOperations.cs b/Terminal.Gui/FileServices/DefaultFileOperations.cs index a8fad43ef3..bdbc889641 100644 --- a/Terminal.Gui/FileServices/DefaultFileOperations.cs +++ b/Terminal.Gui/FileServices/DefaultFileOperations.cs @@ -139,8 +139,8 @@ private bool Prompt (string title, string defaultText, out string result) { 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 @@ private bool Prompt (string title, string defaultText, out string result) { 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 }; diff --git a/Terminal.Gui/Input/CommandEventArgs.cs b/Terminal.Gui/Input/CommandEventArgs.cs index 70e2751d71..b98eb514f0 100644 --- a/Terminal.Gui/Input/CommandEventArgs.cs +++ b/Terminal.Gui/Input/CommandEventArgs.cs @@ -4,9 +4,10 @@ namespace Terminal.Gui; /// -/// Event arguments for events. +/// Event arguments for events. Set to +/// to indicate a command was handled. /// -public class CommandEventArgs : CancelEventArgs +public class CommandEventArgs : HandledEventArgs { /// /// The context for the command, if any. diff --git a/Terminal.Gui/View/Adornment/Border.cs b/Terminal.Gui/View/Adornment/Border.cs index 9700e7e147..c5c2482aa3 100644 --- a/Terminal.Gui/View/Adornment/Border.cs +++ b/Terminal.Gui/View/Adornment/Border.cs @@ -133,7 +133,7 @@ public override void BeginInit () }; CloseButton.Accept += (s, e) => { - e.Cancel = Parent.InvokeCommand (Command.QuitToplevel) == true; + e.Handled = Parent.InvokeCommand (Command.QuitToplevel) == true; }; Add (CloseButton); diff --git a/Terminal.Gui/View/View.Command.cs b/Terminal.Gui/View/View.Command.cs index ec09d75f98..9dec91ffbc 100644 --- a/Terminal.Gui/View/View.Command.cs +++ b/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 @@ private void SetupCommands () AddCommand (Command.Accept, RaiseAccepting); // HotKey - SetFocus and raise HandlingHotKey - AddCommand (Command.HotKey, + AddCommand ( + Command.HotKey, () => { if (RaiseHandlingHotKey () is true) @@ -36,22 +34,24 @@ private void SetupCommands () }); // 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; + }); } /// @@ -59,18 +59,17 @@ private void SetupCommands () /// /// /// if no event was raised; input processing should continue. - /// if the event was raised and was not handled (or cancelled); input processing should continue. + /// if the event was raised and was not handled (or cancelled); input processing should + /// continue. /// if the event was raised and handled (or cancelled); input processing should stop. /// 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 @@ private void SetupCommands () // 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; } /// - /// Called when a command that has not been bound is invoked. - /// Set CommandEventArgs.Cancel to - /// and return to cancel the event. The default implementation does nothing. + /// Called when a command that has not been bound is invoked. + /// Set CommandEventArgs.Handled to and return to indicate the event was + /// handled and processing should stop. /// /// The event arguments. /// to stop processing. @@ -92,28 +91,35 @@ private void SetupCommands () /// /// Cancelable event raised when a command that has not been bound is invoked. + /// Set CommandEventArgs.Handled to to indicate the event was handled and processing should + /// stop. /// public event EventHandler? CommandNotBound; /// - /// Called when the user is accepting the state of the View and the has been invoked. Calls which can be cancelled; if not cancelled raises . + /// Called when the user is accepting the state of the View and the has been invoked. + /// Calls which can be cancelled; if not cancelled raises . /// event. The default handler calls this method. /// /// - /// - /// The event should be 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 . - /// + /// + /// The event should be 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 no event was raised; input processing should continue. - /// if the event was raised and was not handled (or cancelled); input processing should continue. + /// if the event was raised and was not handled (or cancelled); input processing should + /// continue. /// if the event was raised and handled (or cancelled); input processing should stop. /// protected bool? RaiseAccepting (ICommandContext? ctx) @@ -124,9 +130,9 @@ private void SetupCommands () // 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 @@ private void SetupCommands () // 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 @@ private void SetupCommands () // 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 @@ private void SetupCommands () 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; } /// - /// Called when the user is accepting the state of the View and the has been invoked. Set CommandEventArgs.Cancel to - /// and return to stop processing. + /// Called when the user is accepting the state of the View and the has been invoked. + /// Set CommandEventArgs.Handled to and return to indicate the event was + /// handled and processing should stop. /// /// - /// - /// See for more information. - /// + /// + /// See for more information. + /// /// /// /// to stop processing. protected virtual bool OnAccepting (CommandEventArgs args) { return false; } /// - /// Cancelable event raised when the user is accepting the state of the View and the 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 has + /// been invoked. + /// Set CommandEventArgs.Handled to to indicate the event was handled and processing should + /// stop. /// /// - /// - /// See for more information. - /// + /// + /// See for more information. + /// /// public event EventHandler? Accepting; /// - /// Called when the user has performed an action (e.g. ) causing the View to change state. Calls which can be cancelled; if not cancelled raises . + /// Called when the user has performed an action (e.g. ) causing the View to change state. + /// Calls which can be cancelled; if not cancelled raises . /// event. The default handler calls this method. /// /// - /// The event should be raised after the state of the View has been changed and before see . + /// The event should be raised after the state of the View has been changed and before see + /// . /// /// /// if no event was raised; input processing should continue. - /// if the event was raised and was not handled (or cancelled); input processing should continue. + /// if the event was raised and was not handled (or cancelled); input processing should + /// continue. /// if the event was raised and handled (or cancelled); input processing should stop. /// protected bool? RaiseSelecting (ICommandContext? ctx) @@ -207,7 +221,7 @@ private void SetupCommands () // 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 @@ private void SetupCommands () // 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; } /// /// Called when the user has performed an action (e.g. ) causing the View to change state. - /// Set CommandEventArgs.Cancel to - /// and return to cancel the state change. The default implementation does nothing. + /// Set CommandEventArgs.Handled to and return to indicate the event was + /// handled and processing should stop. /// /// The event arguments. /// to stop processing. protected virtual bool OnSelecting (CommandEventArgs args) { return false; } /// - /// Cancelable event raised when the user has performed an action (e.g. ) causing the View to change state. - /// CommandEventArgs.Cancel to to cancel the state change. + /// Cancelable event raised when the user has performed an action (e.g. ) causing the View + /// to change state. + /// Set CommandEventArgs.Handled to to indicate the event was handled and processing should + /// stop. /// public event EventHandler? Selecting; /// - /// Called when the View is handling the user pressing the View's s. Calls which can be cancelled; if not cancelled raises . + /// Called when the View is handling the user pressing the View's s. Calls + /// which can be cancelled; if not cancelled raises . /// event. The default handler calls this method. /// /// /// if no event was raised; input processing should continue. - /// if the event was raised and was not handled (or cancelled); input processing should continue. + /// if the event was raised and was not handled (or cancelled); input processing should + /// continue. /// if the event was raised and handled (or cancelled); input processing should stop. /// protected bool? RaiseHandlingHotKey () { - CommandEventArgs args = new () { Context = new CommandContext () { Command = Command.HotKey } }; + CommandEventArgs args = new () { Context = new CommandContext { 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 @@ private void SetupCommands () // 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; } /// - /// Called when the View is handling the user pressing the View's . Set CommandEventArgs.Cancel to - /// to stop processing. + /// Called when the View is handling the user pressing the View's . + /// Set CommandEventArgs.Handled to to indicate the event was handled and processing should + /// stop. /// /// /// to stop processing. @@ -270,19 +289,20 @@ private void SetupCommands () /// /// Cancelable event raised when the View is handling the user pressing the View's . Set - /// CommandEventArgs.Cancel to cancel the event. + /// CommandEventArgs.Handled to to indicate the event was handled and processing should stop. /// public event EventHandler? HandlingHotKey; #endregion Default Implementation /// - /// Function signature commands. + /// Function signature commands. /// /// Provides context about the circumstances of invoking the command. /// /// if no event was raised; input processing should continue. - /// if the event was raised and was not handled (or cancelled); input processing should continue. + /// if the event was raised and was not handled (or cancelled); input processing should + /// continue. /// if the event was raised and handled (or cancelled); input processing should stop. /// public delegate bool? CommandImplementation (ICommandContext? ctx); @@ -344,8 +364,10 @@ private void SetupCommands () /// The binding that caused the invocation, if any. This will be passed as context with the command. /// /// if no command was found; input processing should continue. - /// if the command was invoked and was not handled (or cancelled); input processing should continue. - /// if the command was invoked the command was handled (or cancelled); input processing should stop. + /// if the command was invoked and was not handled (or cancelled); input processing should + /// continue. + /// if the command was invoked the command was handled (or cancelled); input processing should + /// stop. /// public bool? InvokeCommands (Command [] commands, TBindingType binding) { @@ -359,7 +381,7 @@ private void SetupCommands () } // each command has its own return value - bool? thisReturn = InvokeCommand (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 @@ private void SetupCommands () } /// - /// Invokes the specified command. + /// Invokes the specified command. /// /// The command to invoke. /// The binding that caused the invocation, if any. This will be passed as context with the command. /// /// if no command was found; input processing should continue. - /// if the command was invoked and was not handled (or cancelled); input processing should continue. - /// if the command was invoked the command was handled (or cancelled); input processing should stop. + /// if the command was invoked and was not handled (or cancelled); input processing should + /// continue. + /// if the command was invoked the command was handled (or cancelled); input processing should + /// stop. /// public bool? InvokeCommand (Command command, TBindingType binding) { @@ -390,24 +414,27 @@ private void SetupCommands () { _commandImplementations.TryGetValue (Command.NotBound, out implementation); } - return implementation! (new CommandContext () - { - Command = command, - Source = this, - Binding = binding, - }); - } + return implementation! ( + new CommandContext + { + Command = command, + Source = this, + Binding = binding + }); + } /// - /// Invokes the specified command. + /// Invokes the specified command. /// /// The command to invoke. /// The context to pass with the command. /// /// if no command was found; input processing should continue. - /// if the command was invoked and was not handled (or cancelled); input processing should continue. - /// if the command was invoked the command was handled (or cancelled); input processing should stop. + /// if the command was invoked and was not handled (or cancelled); input processing should + /// continue. + /// if the command was invoked the command was handled (or cancelled); input processing should + /// stop. /// public bool? InvokeCommand (Command command, ICommandContext? ctx) { @@ -415,17 +442,20 @@ private void SetupCommands () { _commandImplementations.TryGetValue (Command.NotBound, out implementation); } + return implementation! (ctx); } /// - /// Invokes the specified command without context. + /// Invokes the specified command without context. /// /// The command to invoke. /// /// if no command was found; input processing should continue. - /// if the command was invoked and was not handled (or cancelled); input processing should continue. - /// if the command was invoked the command was handled (or cancelled); input processing should stop. + /// if the command was invoked and was not handled (or cancelled); input processing should + /// continue. + /// if the command was invoked the command was handled (or cancelled); input processing should + /// stop. /// public bool? InvokeCommand (Command command) { @@ -434,12 +464,12 @@ private void SetupCommands () _commandImplementations.TryGetValue (Command.NotBound, out implementation); } - return implementation! (new CommandContext () - { - Command = command, - Source = this, - Binding = null, - }); - + return implementation! ( + new CommandContext + { + Command = command, + Source = this, + Binding = null + }); } } diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs index d42865b698..f9889dd5e2 100644 --- a/Terminal.Gui/Views/CheckBox.cs +++ b/Terminal.Gui/Views/CheckBox.cs @@ -180,7 +180,7 @@ public CheckState CheckedState /// Called when the state is changing. /// /// - /// The state cahnge can be cancelled by setting the args.Cancel to . + /// The state change can be cancelled by setting the args.Cancel to . /// /// protected virtual bool OnCheckedStateChanging (CancelEventArgs args) { return false; } diff --git a/Terminal.Gui/Views/ColorPicker.Prompt.cs b/Terminal.Gui/Views/ColorPicker.Prompt.cs index 8afa35a877..fdc2ac94cf 100644 --- a/Terminal.Gui/Views/ColorPicker.Prompt.cs +++ b/Terminal.Gui/Views/ColorPicker.Prompt.cs @@ -36,7 +36,7 @@ public static bool Prompt (string title, Attribute? currentAttribute, out Attrib btnOk.Accepting += (s, e) => { accept = true; - e.Cancel = true; + e.Handled = true; Application.RequestStop (); }; @@ -50,7 +50,7 @@ public static bool Prompt (string title, Attribute? currentAttribute, out Attrib btnCancel.Accepting += (s, e) => { - e.Cancel = true; + e.Handled = true; Application.RequestStop (); }; diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs index 2cfe37103e..3b13726591 100644 --- a/Terminal.Gui/Views/ComboBox.cs +++ b/Terminal.Gui/Views/ComboBox.cs @@ -39,7 +39,7 @@ public ComboBox () _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 (); diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index c715a99869..6bc3b43557 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -83,7 +83,7 @@ internal FileDialog (IFileSystem fileSystem) _btnOk.Accepting += (s, e) => { - if (e.Cancel) + if (e.Handled) { return; } @@ -100,12 +100,12 @@ internal FileDialog (IFileSystem fileSystem) _btnCancel.Accepting += (s, e) => { - if (e.Cancel) + if (e.Handled) { return; } - e.Cancel = true; + e.Handled = true; if (Modal) { @@ -118,7 +118,7 @@ internal FileDialog (IFileSystem fileSystem) _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 @@ internal FileDialog (IFileSystem fileSystem) _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 @@ internal FileDialog (IFileSystem fileSystem) _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 @@ internal FileDialog (IFileSystem fileSystem) _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; diff --git a/Terminal.Gui/Views/FlagSelector.cs b/Terminal.Gui/Views/FlagSelector.cs index 0923f155b0..4013dc806c 100644 --- a/Terminal.Gui/Views/FlagSelector.cs +++ b/Terminal.Gui/Views/FlagSelector.cs @@ -370,14 +370,14 @@ protected virtual CheckBox CreateCheckBox (string name, uint flag) { 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; } }; diff --git a/Terminal.Gui/Views/Menu/PopoverMenu.cs b/Terminal.Gui/Views/Menu/PopoverMenu.cs index ff891b7bb0..80629b56eb 100644 --- a/Terminal.Gui/Views/Menu/PopoverMenu.cs +++ b/Terminal.Gui/Views/Menu/PopoverMenu.cs @@ -490,8 +490,8 @@ private void MenuOnAccepting (object? sender, CommandEventArgs e) { 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 @@ protected override bool OnAccepting (CommandEventArgs args) 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 diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index f7b2979f51..80be7d4713 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -371,7 +371,7 @@ params string [] buttons if (e is { }) { - e.Cancel = true; + e.Handled = true; } Application.RequestStop (); diff --git a/Terminal.Gui/Views/NumericUpDown.cs b/Terminal.Gui/Views/NumericUpDown.cs index ab5ca3791f..5e6155913e 100644 --- a/Terminal.Gui/Views/NumericUpDown.cs +++ b/Terminal.Gui/Views/NumericUpDown.cs @@ -148,13 +148,13 @@ public NumericUpDown () 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 @@ void OnUpButtonOnAccept (object? s, CommandEventArgs e) /// /// and events are raised when the value changes. /// The event can be canceled the change setting - /// .Cancel to . + /// .Handled to . /// /// public T Value diff --git a/Terminal.Gui/Views/OptionSelector.cs b/Terminal.Gui/Views/OptionSelector.cs index 02e1067d97..87817298b9 100644 --- a/Terminal.Gui/Views/OptionSelector.cs +++ b/Terminal.Gui/Views/OptionSelector.cs @@ -228,7 +228,7 @@ protected virtual CheckBox CreateCheckBox (string name, int index) { if (RaiseSelecting (args.Context) is true) { - args.Cancel = true; + args.Handled = true; return; } @@ -236,7 +236,7 @@ protected virtual CheckBox CreateCheckBox (string name, int index) if (RaiseAccepting (args.Context) is true) { - args.Cancel = true; + args.Handled = true; } }; diff --git a/Terminal.Gui/Views/ScrollBar/ScrollBar.cs b/Terminal.Gui/Views/ScrollBar/ScrollBar.cs index 1d9885c2af..6e84aa677b 100644 --- a/Terminal.Gui/Views/ScrollBar/ScrollBar.cs +++ b/Terminal.Gui/Views/ScrollBar/ScrollBar.cs @@ -87,13 +87,13 @@ public ScrollBar () 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; } } diff --git a/Terminal.Gui/Views/Shortcut.cs b/Terminal.Gui/Views/Shortcut.cs index ed1464ff7a..13a59bcbfc 100644 --- a/Terminal.Gui/Views/Shortcut.cs +++ b/Terminal.Gui/Views/Shortcut.cs @@ -450,7 +450,7 @@ public View CommandView 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 @@ void CommandViewOnSelecting (object? sender, CommandEventArgs e) InvokeCommand (Command.Select, new ([Command.Select], null, this)); } - e.Cancel = true; + e.Handled = true; } } } diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs index 38238f7444..bf78dcdb5f 100644 --- a/Terminal.Gui/Views/StatusBar.cs +++ b/Terminal.Gui/Views/StatusBar.cs @@ -140,7 +140,7 @@ bool IDesignable.EnableForDesign () { button1.Visible = !button1.Visible; button1.Enabled = button1.Visible; - e.Cancel = false; + e.Handled = false; }; Add (new Label diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index 0bff72f2f7..cbc6caab91 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -453,7 +453,7 @@ private void BackBtn_Accepting (object? sender, CommandEventArgs e) if (!args.Cancel) { - e.Cancel = GoBack (); + e.Handled = GoBack (); } } @@ -471,7 +471,7 @@ private void NextFinishBtn_Accepting (object? sender, CommandEventArgs e) 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 @@ private void NextFinishBtn_Accepting (object? sender, CommandEventArgs e) if (!args.Cancel) { - e.Cancel = GoNext (); + e.Handled = GoNext (); } } } diff --git a/Tests/UnitTests/View/ViewCommandTests.cs b/Tests/UnitTests/View/ViewCommandTests.cs index a9a8273aee..5f1d40fe40 100644 --- a/Tests/UnitTests/View/ViewCommandTests.cs +++ b/Tests/UnitTests/View/ViewCommandTests.cs @@ -28,7 +28,7 @@ public void Button_IsDefault_Raises_Accepted_Correctly () btnA.Accepting += (s, e) => { aAcceptedCount++; - e.Cancel = aCancelAccepting; + e.Handled = aCancelAccepting; }; var btnB = new Button () @@ -40,7 +40,7 @@ public void Button_IsDefault_Raises_Accepted_Correctly () btnB.Accepting += (s, e) => { bAcceptedCount++; - e.Cancel = bCancelAccepting; + e.Handled = bCancelAccepting; }; w.Add (btnA, btnB); @@ -96,7 +96,7 @@ public void Button_CanFocus_False_Raises_Accepted_Correctly () w.Accepting += (s, e) => { wAcceptedCount++; - e.Cancel = wCancelAccepting; + e.Handled = wCancelAccepting; }; int btnAcceptedCount = 0; @@ -112,7 +112,7 @@ public void Button_CanFocus_False_Raises_Accepted_Correctly () btn.Accepting += (s, e) => { btnAcceptedCount++; - e.Cancel = btnCancelAccepting; + e.Handled = btnCancelAccepting; }; w.Add (btn); diff --git a/Tests/UnitTests/Views/ButtonTests.cs b/Tests/UnitTests/Views/ButtonTests.cs index c5de4070b8..2e84f96ab7 100644 --- a/Tests/UnitTests/Views/ButtonTests.cs +++ b/Tests/UnitTests/Views/ButtonTests.cs @@ -513,7 +513,7 @@ public void Accept_Cancel_Event_OnAccept_Returns_True () void ButtonAccept (object sender, CommandEventArgs e) { acceptInvoked = true; - e.Cancel = true; + e.Handled = true; } } @@ -616,7 +616,7 @@ public void WantContinuousButtonPressed_True_ButtonClick_Accepts (MouseFlags pre button.Accepting += (s, e) => { acceptedCount++; - e.Cancel = true; + e.Handled = true; }; me = new (); @@ -661,7 +661,7 @@ public void WantContinuousButtonPressed_True_ButtonPressRelease_Does_Not_Raise_S button.Accepting += (s, e) => { acceptedCount++; - e.Cancel = true; + e.Handled = true; }; var selectingCount = 0; @@ -669,7 +669,7 @@ public void WantContinuousButtonPressed_True_ButtonPressRelease_Does_Not_Raise_S button.Selecting += (s, e) => { selectingCount++; - e.Cancel = true; + e.Handled = true; }; me.Flags = pressed; diff --git a/Tests/UnitTests/Views/CheckBoxTests.cs b/Tests/UnitTests/Views/CheckBoxTests.cs index e7594f17ba..8c4c31c76a 100644 --- a/Tests/UnitTests/Views/CheckBoxTests.cs +++ b/Tests/UnitTests/Views/CheckBoxTests.cs @@ -246,7 +246,7 @@ public void Accept_Cancel_Event_OnAccept_Returns_True () void ViewOnAccept (object sender, CommandEventArgs e) { acceptInvoked = true; - e.Cancel = true; + e.Handled = true; } } @@ -313,7 +313,7 @@ public void Mouse_DoubleClick_Accepts () checkBox.Accepting += (s, e) => { acceptCount++; - e.Cancel = true; + e.Handled = true; }; checkBox.HasFocus = true; @@ -596,7 +596,7 @@ public void Selected_Handle_Event_Does_Not_Prevent_Change (CheckState initialSta void OnSelecting (object sender, CommandEventArgs e) { checkedInvoked = true; - e.Cancel = true; + e.Handled = true; } } diff --git a/Tests/UnitTests/Views/ListViewTests.cs b/Tests/UnitTests/Views/ListViewTests.cs index 91f4d6d11a..465d88f3cd 100644 --- a/Tests/UnitTests/Views/ListViewTests.cs +++ b/Tests/UnitTests/Views/ListViewTests.cs @@ -488,7 +488,7 @@ void OpenSelectedItem (object sender, ListViewItemEventArgs e) void Accepted (object sender, CommandEventArgs e) { accepted = true; - e.Cancel = true; + e.Handled = true; } } diff --git a/Tests/UnitTests/Views/RadioGroupTests.cs b/Tests/UnitTests/Views/RadioGroupTests.cs index 65db918a34..ba11583050 100644 --- a/Tests/UnitTests/Views/RadioGroupTests.cs +++ b/Tests/UnitTests/Views/RadioGroupTests.cs @@ -689,7 +689,7 @@ public void Mouse_DoubleClick_Accepts () radioGroup.Accepting += (s, e) => { acceptedCount++; - e.Cancel = handleAccepted; + e.Handled = handleAccepted; }; Assert.True (radioGroup.DoubleClickAccepts); @@ -742,7 +742,7 @@ public void Mouse_DoubleClick_Accepts () superView.Accepting += (s, a) => { superViewAcceptCount++; - a.Cancel = true; + a.Handled = true; }; Assert.Equal (0, superViewAcceptCount); diff --git a/Tests/UnitTests/Views/ShortcutTests.cs b/Tests/UnitTests/Views/ShortcutTests.cs index e2ec41983a..0a63bee178 100644 --- a/Tests/UnitTests/Views/ShortcutTests.cs +++ b/Tests/UnitTests/Views/ShortcutTests.cs @@ -205,7 +205,7 @@ public void MouseClick_CheckBox_CommandView_Raises_Shortcut_Accepted_Selected_Co var checkboxSelected = 0; shortcut.CommandView.Selecting += (s, e) => { - if (e.Cancel) + if (e.Handled) { return; } @@ -226,7 +226,7 @@ public void MouseClick_CheckBox_CommandView_Raises_Shortcut_Accepted_Selected_Co shortcut.Accepting += (s, e) => { accepted++; - e.Cancel = true; + e.Handled = true; }; Application.RaiseMouseEvent ( @@ -326,7 +326,7 @@ public void KeyDown_CheckBox_Raises_Accepted_Selected (bool canFocus, KeyCode ke shortcut.Accepting += (s, e) => { accepted++; - e.Cancel = true; + e.Handled = true; }; var selected = 0; diff --git a/Tests/UnitTests/Views/TextFieldTests.cs b/Tests/UnitTests/Views/TextFieldTests.cs index fd69ea289b..f57d0d6ee6 100644 --- a/Tests/UnitTests/Views/TextFieldTests.cs +++ b/Tests/UnitTests/Views/TextFieldTests.cs @@ -765,7 +765,7 @@ public void Accepted_Handler_Handled_Prevents_Default_Button_Accept (bool handle void TextFieldAccept (object sender, CommandEventArgs e) { textFieldAccept++; - e.Cancel = handleAccept; + e.Handled = handleAccept; } void ButtonAccept (object sender, CommandEventArgs e) { buttonAccept++; } diff --git a/Tests/UnitTests/Views/TextViewTests.cs b/Tests/UnitTests/Views/TextViewTests.cs index de4db0a049..f6d36bfc01 100644 --- a/Tests/UnitTests/Views/TextViewTests.cs +++ b/Tests/UnitTests/Views/TextViewTests.cs @@ -8687,7 +8687,7 @@ public void Accepted_Event_Handled_Prevents_Default_Button_Accept (bool multilin void TextViewAccept (object sender, CommandEventArgs e) { textViewAccept++; - e.Cancel = handleAccept; + e.Handled = handleAccept; } void ButtonAccept (object sender, CommandEventArgs e) { buttonAccept++; } diff --git a/Tests/UnitTests/Views/TreeViewTests.cs b/Tests/UnitTests/Views/TreeViewTests.cs index 827a4bb842..f0a9129480 100644 --- a/Tests/UnitTests/Views/TreeViewTests.cs +++ b/Tests/UnitTests/Views/TreeViewTests.cs @@ -1425,7 +1425,7 @@ void ObjectActivated (object sender, ObjectActivatedEventArgs e) void Accept (object sender, CommandEventArgs e) { accepted = true; - e.Cancel = true; + e.Handled = true; } } } diff --git a/Tests/UnitTestsParallelizable/View/ViewCommandTests.cs b/Tests/UnitTestsParallelizable/View/ViewCommandTests.cs index 5671dbd9e3..86418d9309 100644 --- a/Tests/UnitTestsParallelizable/View/ViewCommandTests.cs +++ b/Tests/UnitTestsParallelizable/View/ViewCommandTests.cs @@ -49,7 +49,7 @@ public void Accept_Handle_Event_OnAccept_Returns_True () void ViewOnAccept (object sender, CommandEventArgs e) { acceptInvoked = true; - e.Cancel = true; + e.Handled = true; } } @@ -180,7 +180,7 @@ public void Select_Handle_Event_OnSelecting_Returns_True () void ViewOnSelect (object sender, CommandEventArgs e) { selectingInvoked = true; - e.Cancel = true; + e.Handled = true; } } @@ -276,25 +276,25 @@ public ViewEventTester () 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++; }; } diff --git a/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs b/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs index d9019dfff5..4d6f630a7e 100644 --- a/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs +++ b/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs @@ -200,7 +200,7 @@ public void Accepted_Cancel_Event_HandlesCommand () void TextViewAccept (object sender, CommandEventArgs e) { tfAcceptedInvoked = true; - e.Cancel = handle; + e.Handled = handle; } }