diff --git a/CommunityToolkitExample/LoginView.cs b/CommunityToolkitExample/LoginView.cs index b0d891fa9..d3d4b6496 100644 --- a/CommunityToolkitExample/LoginView.cs +++ b/CommunityToolkitExample/LoginView.cs @@ -19,13 +19,13 @@ internal partial class LoginView : IRecipient> { ViewModel.Password = passwordInput.Text; }; - loginButton.Accept += (_, _) => + loginButton.Accepted += (_, _) => { if (!ViewModel.CanLogin) { return; } ViewModel.LoginCommand.Execute (null); }; - clearButton.Accept += (_, _) => + clearButton.Accepted += (_, _) => { ViewModel.ClearCommand.Execute (null); }; diff --git a/Example/Example.cs b/Example/Example.cs index 13c7b9138..f34f0d095 100644 --- a/Example/Example.cs +++ b/Example/Example.cs @@ -63,7 +63,7 @@ public class ExampleWindow : Window }; // When login button is clicked display a message popup - btnLogin.Accept += (s, e) => + btnLogin.Accepted += (s, e) => { if (userNameText.Text == "admin" && passwordText.Text == "password") { diff --git a/NativeAot/Program.cs b/NativeAot/Program.cs index 4aae3c099..be71b81e8 100644 --- a/NativeAot/Program.cs +++ b/NativeAot/Program.cs @@ -93,7 +93,7 @@ public class ExampleWindow : Window }; // When login button is clicked display a message popup - btnLogin.Accept += (s, e) => + btnLogin.Accepted += (s, e) => { if (userNameText.Text == "admin" && passwordText.Text == "password") { diff --git a/ReactiveExample/LoginView.cs b/ReactiveExample/LoginView.cs index a69d38f84..4037e69f3 100644 --- a/ReactiveExample/LoginView.cs +++ b/ReactiveExample/LoginView.cs @@ -108,7 +108,7 @@ public class LoginView : Window, IViewFor login .Events () - .Accept + .Accepted .InvokeCommand (ViewModel, x => x.Login) .DisposeWith (_disposable); }) @@ -120,7 +120,7 @@ public class LoginView : Window, IViewFor clear .Events () - .Accept + .Accepted .InvokeCommand (ViewModel, x => x.ClearCommand) .DisposeWith (_disposable); }) diff --git a/SelfContained/Program.cs b/SelfContained/Program.cs index 67d8f935c..5c52e215d 100644 --- a/SelfContained/Program.cs +++ b/SelfContained/Program.cs @@ -92,7 +92,7 @@ public class ExampleWindow : Window }; // When login button is clicked display a message popup - btnLogin.Accept += (s, e) => + btnLogin.Accepted += (s, e) => { if (userNameText.Text == "admin" && passwordText.Text == "password") { diff --git a/Terminal.Gui/Application/Application.cs b/Terminal.Gui/Application/Application.cs index 968883836..4f83ef5a8 100644 --- a/Terminal.Gui/Application/Application.cs +++ b/Terminal.Gui/Application/Application.cs @@ -214,8 +214,6 @@ public static partial class Application AddApplicationKeyBindings (); - Colors.Reset (); - // Reset synchronization context to allow the user to run async/await, // as the main loop has been ended, the synchronization context from // gui.cs does no longer process any callbacks. See #1084 for more details: diff --git a/Terminal.Gui/FileServices/DefaultFileOperations.cs b/Terminal.Gui/FileServices/DefaultFileOperations.cs index 85f450fd2..eae31479b 100644 --- a/Terminal.Gui/FileServices/DefaultFileOperations.cs +++ b/Terminal.Gui/FileServices/DefaultFileOperations.cs @@ -135,14 +135,14 @@ public class DefaultFileOperations : IFileOperations var confirm = false; var btnOk = new Button { IsDefault = true, Text = Strings.btnOk }; - btnOk.Accept += (s, e) => + btnOk.Accepted += (s, e) => { confirm = true; Application.RequestStop (); }; var btnCancel = new Button { Text = Strings.btnCancel }; - btnCancel.Accept += (s, e) => + btnCancel.Accepted += (s, e) => { confirm = false; Application.RequestStop (); diff --git a/Terminal.Gui/Input/Command.cs b/Terminal.Gui/Input/Command.cs index 98c681952..c8386c3c9 100644 --- a/Terminal.Gui/Input/Command.cs +++ b/Terminal.Gui/Input/Command.cs @@ -15,9 +15,8 @@ public enum Command /// /// Accepts the current state of the View (e.g. list selection, button press, checkbox state, etc.). /// - /// The default implementation in calls which raises the - /// event. If the event is not handled, - /// the command is invoked on + /// The default implementation in calls . If the event is not handled, + /// the command is invoked on: /// - Any peer-view that is a with set to . /// - The . This enables default Accept behavior. /// @@ -28,17 +27,15 @@ public enum Command /// Performs a hot key action (e.g. setting focus, accepting, and/or moving focus to the next View). /// /// The default implementation in calls and then - /// which raises the - /// event. + /// . /// /// HotKey, /// - /// Selects an item (e.g. a list item or menu item) without necessarily accepting it. + /// Selects the View or an item in the View (e.g. a list item or menu item) without necessarily accepting it. /// - /// The default implementation in calls which raises the - /// event. + /// The default implementation in calls . /// /// Select, diff --git a/Terminal.Gui/Input/KeyBindings.cs b/Terminal.Gui/Input/KeyBindings.cs index 6e1d86a13..04b7b9f3c 100644 --- a/Terminal.Gui/Input/KeyBindings.cs +++ b/Terminal.Gui/Input/KeyBindings.cs @@ -284,7 +284,6 @@ public class KeyBindings return Array.Empty (); } - // TODO: Consider having this return all keys bound to the commands /// Gets the first Key bound to the set of commands specified by . /// The set of commands to search. /// The first bound to the set of commands specified by . if the set of caommands was not found. @@ -293,6 +292,14 @@ public class KeyBindings return Bindings.FirstOrDefault (a => a.Value.Commands.SequenceEqual (commands)).Key; } + /// Gets Keys bound to the set of commands specified by . + /// The set of commands to search. + /// The s bound to the set of commands specified by . An empty list if the set of caommands was not found. + public IEnumerable GetKeysFromCommands (params Command [] commands) + { + return Bindings.Where (a => a.Value.Commands.SequenceEqual (commands)).Select (a => a.Key); + } + /// Removes a from the collection. /// /// Optional View for bindings. diff --git a/Terminal.Gui/View/Adornment/Margin.cs b/Terminal.Gui/View/Adornment/Margin.cs index cdcb895a8..818b19698 100644 --- a/Terminal.Gui/View/Adornment/Margin.cs +++ b/Terminal.Gui/View/Adornment/Margin.cs @@ -18,7 +18,8 @@ public class Margin : Adornment { /* Do nothing; View.CreateAdornment requires a constructor that takes a parent */ - HighlightStyle |= HighlightStyle.Pressed; + // BUGBUG: We should not set HighlightStyle.Pressed here, but wherever it is actually needed + // HighlightStyle |= HighlightStyle.Pressed; Highlight += Margin_Highlight; LayoutStarted += Margin_LayoutStarted; diff --git a/Terminal.Gui/View/View.Command.cs b/Terminal.Gui/View/View.Command.cs index ff3ca5f22..cfdae3ce6 100644 --- a/Terminal.Gui/View/View.Command.cs +++ b/Terminal.Gui/View/View.Command.cs @@ -12,40 +12,56 @@ public partial class View // Command APIs /// private void SetupCommands () { - AddCommand (Command.Accept, RaiseAcceptEvent); + // Enter - Raise Accepted + AddCommand (Command.Accept, RaiseAccepted); - AddCommand ( - Command.HotKey, + // HotKey - SetFocus and raise HotKeyHandled + AddCommand (Command.HotKey, () => { SetFocus (); - return RaiseHotKeyCommandEvent (); + return RaiseHotKeyHandled (); }); - AddCommand (Command.Select, RaiseSelectEvent); + // Space or single-click - Raise Selected + AddCommand (Command.Select, () => + { + bool? cancelled = RaiseSelected (); + if (cancelled is null or false && CanFocus) + { + SetFocus (); + + return true; + } + + return cancelled is true; + }); } /// - /// Called when the command is invoked. Raises - /// event. + /// Called when the View's state has been accepted by the user. Calls which can be cancelled; if not cancelled raises . + /// event. The default handler calls this method. /// + /// + /// The event should raised after the state of the View has changed (after is raised). + /// /// /// If the event was canceled. If the event was raised but not canceled. /// If no event was raised. /// - protected bool? RaiseAcceptEvent () + protected bool? RaiseAccepted () { HandledEventArgs args = new (); // Best practice is to invoke the virtual method first. // This allows derived classes to handle the event and potentially cancel it. - args.Handled = OnAccept (args) || args.Handled; + args.Handled = OnAccepted (args) || args.Handled; if (!args.Handled) { // If the event is not canceled by the virtual method, raise the event to notify any external subscribers. - Accept?.Invoke (this, args); + Accepted?.Invoke (this, args); } // Accept is a special case where if the event is not canceled, the event is @@ -68,108 +84,108 @@ public partial class View // Command APIs return SuperView?.InvokeCommand (Command.Accept) == true; } - return Accept is null ? null : args.Handled; + return Accepted is null ? null : args.Handled; } + // TODO: Change this to CancelEventArgs /// - /// Called when the command is received. Set to + /// Called when the View's state has been accepted by the user. Set to /// to stop processing. /// /// /// to stop processing. - protected virtual bool OnAccept (HandledEventArgs args) { return false; } + protected virtual bool OnAccepted (HandledEventArgs args) { return false; } /// - /// Cancelable event raised when the command is invoked. Set - /// - /// to cancel the event. + /// Cancelable event raised when the View's state has been accepted by the user. Set + /// to cancel the event. /// - public event EventHandler? Accept; + public event EventHandler? Accepted; /// - /// Called when the command is invoked. Raises - /// event. + /// Called when the user has selected the View or otherwise changed the state of the View. Calls which can be cancelled; if not cancelled raises . + /// event. The default handler calls this method. /// + /// + /// The event should raised after the state of the View has been changed and before see . + /// /// /// If the event was canceled. If the event was raised but not canceled. /// If no event was raised. /// - protected bool? RaiseSelectEvent () + protected bool? RaiseSelected () { HandledEventArgs args = new (); // Best practice is to invoke the virtual method first. // This allows derived classes to handle the event and potentially cancel it. - if (OnSelect (args) || args.Handled) + if (OnSelected (args) || args.Handled) { return true; } // If the event is not canceled by the virtual method, raise the event to notify any external subscribers. - Select?.Invoke (this, args); + Selected?.Invoke (this, args); - if ((Select is null || !args.Handled) && CanFocus) - { - SetFocus (); - } - - return Select is null ? null : args.Handled; + return Selected is null ? null : args.Handled; } /// - /// Called when the command is received. Set to + /// Called when the user has selected the View or otherwise changed the state of the View. Set to /// to stop processing. /// /// /// to stop processing. - protected virtual bool OnSelect (HandledEventArgs args) { return false; } + protected virtual bool OnSelected (HandledEventArgs args) { return false; } /// - /// Cancelable event raised when the command is invoked. Set + /// Cancelable event raised when the user has selected the View or otherwise changed the state of the View. Set /// /// to cancel the event. /// - public event EventHandler? Select; + public event EventHandler? Selected; + + // TODO: What does this event really do? "Called when the user has pressed the View's hot key or otherwise invoked the View's hot key command.???" /// - /// Called when the command is invoked. Raises - /// event. + /// Called when the View has handled the user pressing the View's . Calls which can be cancelled; if not cancelled raises . + /// event. The default handler calls this method. /// /// /// If the event was handled. If the event was raised but not handled. /// If no event was raised. /// - protected bool? RaiseHotKeyCommandEvent () + protected bool? RaiseHotKeyHandled () { HandledEventArgs args = new (); // Best practice is to invoke the virtual method first. // This allows derived classes to handle the event and potentially cancel it. - if (OnHotKeyCommand (args) || args.Handled) + if (OnHotKeyHandled (args) || args.Handled) { return true; } // If the event is not canceled by the virtual method, raise the event to notify any external subscribers. - HotKeyCommand?.Invoke (this, args); + HotKeyHandled?.Invoke (this, args); - return HotKeyCommand is null ? null : args.Handled; + return HotKeyHandled is null ? null : args.Handled; } /// - /// Called when the command is received. Set to + /// Called when the View has handled the user pressing the View's . Set to /// to stop processing. /// /// /// to stop processing. - protected virtual bool OnHotKeyCommand (HandledEventArgs args) { return false; } + protected virtual bool OnHotKeyHandled (HandledEventArgs args) { return false; } /// /// Cancelable event raised when the command is invoked. Set /// /// to cancel the event. /// - public event EventHandler? HotKeyCommand; + public event EventHandler? HotKeyHandled; #endregion Default Implementation @@ -227,7 +243,7 @@ public partial class View // Command APIs /// /// /// if no command was found. - /// if the command was invoked the command was handled. + /// if the command was invoked the command was handled (or cancelled) /// if the command was invoked and the command was not handled. /// public bool? InvokeCommands (Command [] commands, Key? key = null, KeyBinding? keyBinding = null) @@ -263,7 +279,7 @@ public partial class View // Command APIs /// /// /// if no command was found. if the command was invoked, and it - /// handled the command. if the command was invoked, and it did not handle the command. + /// handled (or cancelled) the command. if the command was invoked, and it did not handle (or cancel) the command. /// public bool? InvokeCommand (Command command, Key? key = null, KeyBinding? keyBinding = null) { diff --git a/Terminal.Gui/View/View.Keyboard.cs b/Terminal.Gui/View/View.Keyboard.cs index 8db31c656..2f32b4ef8 100644 --- a/Terminal.Gui/View/View.Keyboard.cs +++ b/Terminal.Gui/View/View.Keyboard.cs @@ -39,7 +39,7 @@ public partial class View // Keyboard APIs /// /// A HotKey is a keypress that causes a visible UI item to perform an action. For example, in a Dialog, /// with a Button with the text of "_Text" Alt+T will cause the button to gain focus and to raise its - /// event. + /// event. /// Or, in a /// with "_File _Edit", Alt+F will select (show) the "_File" menu. If the "_File" menu /// has a diff --git a/Terminal.Gui/View/View.Mouse.cs b/Terminal.Gui/View/View.Mouse.cs index 836f1cd50..837ecbfff 100644 --- a/Terminal.Gui/View/View.Mouse.cs +++ b/Terminal.Gui/View/View.Mouse.cs @@ -399,6 +399,7 @@ public partial class View // Mouse APIs if (SetPressedHighlight (HighlightStyle.None)) { + // BUGBUG: If we retrun true here we never generate a moues click! return true; } diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index 922357a38..681f0d7d2 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -8,12 +8,12 @@ namespace Terminal.Gui; /// -/// A View that raises the event when clicked with the mouse or when the +/// A View that raises the event when clicked with the mouse or when the /// , Enter, or Space key is pressed. /// /// /// -/// Provides a button showing text that raises the event when clicked on with a mouse or +/// Provides a button showing text that raises the event when clicked on with a mouse or /// when the user presses Enter, Space or the . The hot key is the first /// letter or digit /// following the first underscore ('_') in the button text. @@ -21,13 +21,13 @@ namespace Terminal.Gui; /// Use to change the hot key specifier from the default of ('_'). /// /// When the button is configured as the default () and the user causes the button to be -/// accepted the 's event will be raised. If the Accept event is not +/// accepted the 's event will be raised. If the Accept event is not /// handled, the Accept event on the . will be raised. This enables default Accept /// behavior. /// /// /// Set to to have the -/// event +/// event /// invoked repeatedly while the button is pressed. /// /// @@ -74,7 +74,7 @@ public class Button : View, IDesignable { bool cachedIsDefault = IsDefault; // Supports "Swap Default" in Buttons scenario where IsDefault changes - bool? handled = RaiseAcceptEvent (); + bool? handled = RaiseAccepted (); if (handled == true) { @@ -159,7 +159,7 @@ public class Button : View, IDesignable /// /// will be invoked when the user presses Enter and no other peer- /// processes the key. - /// If is not handled, the Gets or sets whether the will show an + /// If is not handled, the Gets or sets whether the will show an /// indicator indicating it is the default Button. If /// command on the will be invoked. /// diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs index 194c01a71..b91ddb46d 100644 --- a/Terminal.Gui/Views/CheckBox.cs +++ b/Terminal.Gui/Views/CheckBox.cs @@ -23,13 +23,39 @@ public class CheckBox : View CanFocus = true; // Select (Space key and single-click) - Advance state and raise Select event - AddCommand (Command.Select, () => AdvanceCheckState () is false); + AddCommand (Command.Select, () => + { + bool? cancelled = AdvanceCheckState (); - // Accept (Enter key and double-click) - Raise Accept event - DO NOT advance state - AddCommand (Command.Accept, () => RaiseAcceptEvent ()); + if (cancelled is null or false) + { + if (RaiseSelected () == true) + { + return true; + } + } + + return cancelled is false; + }); + + // Accept (Enter key) - Raise Accept event - DO NOT advance state + AddCommand (Command.Accept, () => RaiseAccepted ()); // Hotkey - Advance state and raise Select event - DO NOT raise Accept - AddCommand (Command.HotKey, () => AdvanceCheckState () is false); + AddCommand (Command.HotKey, () => + { + bool? cancelled = AdvanceCheckState (); + + if (cancelled is null or false) + { + if (RaiseSelected () == true) + { + return true; + } + } + + return cancelled; + }); TitleChanged += Checkbox_TitleChanged; @@ -41,8 +67,7 @@ public class CheckBox : View { if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked)) { - // AdvanceCheckState returns false if the state was changed - e.Handled = AdvanceCheckState () is false; + e.Handled = InvokeCommand (Command.Select) is true; } } @@ -215,14 +240,6 @@ public class CheckBox : View bool? cancelled = ChangeCheckedState (e.NewValue); - if (cancelled is null or false) - { - if (RaiseSelectEvent () == true) - { - return true; - } - } - return cancelled; } diff --git a/Terminal.Gui/Views/ColorPicker.cs b/Terminal.Gui/Views/ColorPicker.cs index 9c5cec83b..7ecb76bff 100644 --- a/Terminal.Gui/Views/ColorPicker.cs +++ b/Terminal.Gui/Views/ColorPicker.cs @@ -64,7 +64,7 @@ public class ColorPicker : View Width = textFieldWidth }; tfValue.HasFocusChanged += UpdateSingleBarValueFromTextField; - tfValue.Accept += (s, _)=>UpdateSingleBarValueFromTextField(s); + tfValue.Accepted += (s, _)=>UpdateSingleBarValueFromTextField(s); _textFields.Add (bar, tfValue); } @@ -154,7 +154,7 @@ public class ColorPicker : View _tfName.Autocomplete = auto; _tfName.HasFocusChanged += UpdateValueFromName; - _tfName.Accept += (s, _) => UpdateValueFromName (); + _tfName.Accepted += (s, _) => UpdateValueFromName (); } private void CreateTextField () @@ -184,7 +184,7 @@ public class ColorPicker : View Add (_tfHex); _tfHex.HasFocusChanged += UpdateValueFromTextField; - _tfHex.Accept += (_,_)=> UpdateValueFromTextField(); + _tfHex.Accepted += (_,_)=> UpdateValueFromTextField(); } private void DisposeOldViews () diff --git a/Terminal.Gui/Views/DatePicker.cs b/Terminal.Gui/Views/DatePicker.cs index 99969df99..d9d47f868 100644 --- a/Terminal.Gui/Views/DatePicker.cs +++ b/Terminal.Gui/Views/DatePicker.cs @@ -227,7 +227,7 @@ public class DatePicker : View ShadowStyle = ShadowStyle.None }; - _previousMonthButton.Accept += (sender, e) => + _previousMonthButton.Accepted += (sender, e) => { Date = _date.AddMonths (-1); CreateCalendar (); @@ -247,7 +247,7 @@ public class DatePicker : View ShadowStyle = ShadowStyle.None }; - _nextMonthButton.Accept += (sender, e) => + _nextMonthButton.Accepted += (sender, e) => { Date = _date.AddMonths (1); CreateCalendar (); diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index 6510a8036..fc8a2ddf6 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -78,7 +78,7 @@ public class FileDialog : Dialog Y = Pos.AnchorEnd (), IsDefault = true, Text = Style.OkButtonText }; - _btnOk.Accept += (s, e) => Accept (true); + _btnOk.Accepted += (s, e) => Accept (true); _btnCancel = new Button @@ -88,7 +88,7 @@ public class FileDialog : Dialog Text = Strings.btnCancel }; - _btnCancel.Accept += (s, e) => + _btnCancel.Accepted += (s, e) => { Canceled = true; Application.RequestStop (); @@ -96,15 +96,15 @@ public class FileDialog : Dialog _btnUp = new Button { X = 0, Y = 1, NoPadding = true }; _btnUp.Text = GetUpButtonText (); - _btnUp.Accept += (s, e) => _history.Up (); + _btnUp.Accepted += (s, e) => _history.Up (); _btnBack = new Button { X = Pos.Right (_btnUp) + 1, Y = 1, NoPadding = true }; _btnBack.Text = GetBackButtonText (); - _btnBack.Accept += (s, e) => _history.Back (); + _btnBack.Accepted += (s, e) => _history.Back (); _btnForward = new Button { X = Pos.Right (_btnBack) + 1, Y = 1, NoPadding = true }; _btnForward.Text = GetForwardButtonText (); - _btnForward.Accept += (s, e) => _history.Forward (); + _btnForward.Accepted += (s, e) => _history.Forward (); _tbPath = new TextField { Width = Dim.Fill (), CaptionColor = new Color (Color.Black) }; @@ -182,7 +182,7 @@ public class FileDialog : Dialog Y = Pos.AnchorEnd (), Text = GetToggleSplitterText (false) }; - _btnToggleSplitterCollapse.Accept += (s, e) => + _btnToggleSplitterCollapse.Accepted += (s, e) => { Tile tile = _splitContainer.Tiles.ElementAt (0); diff --git a/Terminal.Gui/Views/Label.cs b/Terminal.Gui/Views/Label.cs index 05d03d762..2aebe0712 100644 --- a/Terminal.Gui/Views/Label.cs +++ b/Terminal.Gui/Views/Label.cs @@ -27,13 +27,14 @@ public class Label : View Height = Dim.Auto (DimAutoStyle.Text); Width = Dim.Auto (DimAutoStyle.Text); - // Things this view knows how to do + // On HoKey, pass it to the next view AddCommand (Command.HotKey, InvokeHotKeyOnNext); TitleChanged += Label_TitleChanged; MouseClick += Label_MouseClick; } + // TODO: base raises Select, but we want to raise HotKey. This can be simplified? private void Label_MouseClick (object sender, MouseEventEventArgs e) { if (!CanFocus) diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index 579c5e894..5ed8d642b 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -6,7 +6,7 @@ using static Terminal.Gui.SpinnerStyle; namespace Terminal.Gui; /// Implement to provide custom rendering for a . -public interface IListDataSource: IDisposable +public interface IListDataSource : IDisposable { /// /// Event to raise when an item is added, removed, or moved, or the entire list is refreshed. @@ -137,31 +137,47 @@ public class ListView : View, IDesignable AddCommand (Command.ScrollLeft, () => ScrollHorizontal (-1)); AddCommand (Command.ScrollRight, () => ScrollHorizontal (1)); - AddCommand (Command.Accept, () => OnOpenSelectedItem ()); - AddCommand (Command.Open, () => OnOpenSelectedItem ()); - AddCommand (Command.Select, () => + // Accept (Enter key) - Raise Accept event - DO NOT advance state + AddCommand (Command.Accept, () => { - if (RaiseSelectEvent () == true) + if (OnOpenSelectedItem () && RaiseAccepted () == true) { - return true; - - } - if (_allowsMarking) - { - return MarkUnmarkSelectedItem (); + return true; } return false; }); - AddCommand(Command.HotKey, () => - { - if (SelectedItem == -1) - { - SelectedItem = 0; - } - return !SetFocus (); - }); + // Select (Space key and single-click) - If markable, change mark and raise Select event + AddCommand (Command.Select, () => + { + if (_allowsMarking) + { + if (MarkUnmarkSelectedItem () && RaiseSelected () == true) + { + return true; + } + } + + return false; + }); + + + // Hotkey - If none set, select and raise Select event. SetFocus. - DO NOT raise Accept + AddCommand (Command.HotKey, () => + { + if (SelectedItem == -1) + { + SelectedItem = 0; + if (RaiseSelected () == true) + { + return true; + + } + } + + return !SetFocus (); + }); // Default keybindings for all ListViews @@ -179,10 +195,6 @@ public class ListView : View, IDesignable KeyBindings.Add (Key.Home, Command.Start); KeyBindings.Add (Key.End, Command.End); - - // BUGBUG: This should just be Command.Accept - KeyBindings.Remove (Key.Enter); - KeyBindings.Add (Key.Enter, Command.Open); } /// Gets or sets whether this allows items to be marked. @@ -476,9 +488,9 @@ public class ListView : View, IDesignable _selected = Viewport.Y + me.Position.Y; - if (MarkUnmarkSelectedItem()) + if (MarkUnmarkSelectedItem ()) { - // return true; + // return true; } OnSelectedChanged (); @@ -486,7 +498,7 @@ public class ListView : View, IDesignable if (me.Flags == MouseFlags.Button1DoubleClicked) { - return OnOpenSelectedItem (); + return InvokeCommand (Command.Accept) is true; } return true; @@ -774,12 +786,6 @@ public class ListView : View, IDesignable object value = _source.ToList () [_selected]; - // By default, Command.Accept calls OnAccept, so we need to call it here to ensure that the event is fired. - if (RaiseAcceptEvent () == true) - { - return true; - } - OpenSelectedItem?.Invoke (this, new ListViewItemEventArgs (_selected, value)); // BUGBUG: this should not blindly return true. diff --git a/Terminal.Gui/Views/Menuv2.cs b/Terminal.Gui/Views/Menuv2.cs index a07be7073..62b094b22 100644 --- a/Terminal.Gui/Views/Menuv2.cs +++ b/Terminal.Gui/Views/Menuv2.cs @@ -76,7 +76,7 @@ public class Menuv2 : Bar // TODO: instead, add a property (a style enum?) to Shortcut to control this //shortcut.AlignmentModes = AlignmentModes.EndToStart; - shortcut.Accept += ShortcutOnAccept; + shortcut.Accepted += ShortcutOnAccept; void ShortcutOnAccept (object sender, HandledEventArgs e) { diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index 0fbb09e7a..47e615123 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -408,7 +408,7 @@ public static class MessageBox int buttonId = n; Button b = buttonList [n]; - b.Accept += (s, e) => + b.Accepted += (s, e) => { Clicked = buttonId; Application.RequestStop (); diff --git a/Terminal.Gui/Views/NumericUpDown.cs b/Terminal.Gui/Views/NumericUpDown.cs index 784d5c49b..ed9263738 100644 --- a/Terminal.Gui/Views/NumericUpDown.cs +++ b/Terminal.Gui/Views/NumericUpDown.cs @@ -86,8 +86,8 @@ public class NumericUpDown : View where T : notnull CanFocus = true; - _down.Accept += OnDownButtonOnAccept; - _up.Accept += OnUpButtonOnAccept; + _down.Accepted += OnDownButtonOnAccept; + _up.Accepted += OnUpButtonOnAccept; Add (_down, _number, _up); diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs index 8e28a0e86..e89fd8089 100644 --- a/Terminal.Gui/Views/RadioGroup.cs +++ b/Terminal.Gui/Views/RadioGroup.cs @@ -1,4 +1,6 @@ #nullable enable +using System.Diagnostics; + namespace Terminal.Gui; /// Displays a group of labels with an idicator of which one is selected. @@ -76,32 +78,35 @@ public class RadioGroup : View, IDesignable, IOrientation Command.Select, () => { + bool cursorChanged = false; if (SelectedItem == Cursor) { - if (!MoveDownRight ()) + cursorChanged = MoveDownRight (); + if (!cursorChanged) { - MoveHome (); + cursorChanged = MoveHome (); } } - if (ChangeSelectedItem (Cursor) is true) + if (SelectedItem != Cursor) { - return true; - }; - - if (RaiseSelectEvent () == true) - { - return true; + if (ChangeSelectedItem (Cursor) && RaiseSelected () == true) + { + return true; + } } - return false; + return cursorChanged; }); // Accept (Enter key) - Raise Accept event - DO NOT advance state - AddCommand (Command.Accept, RaiseAcceptEvent); + AddCommand (Command.Accept, RaiseAccepted); - AddCommand ( - Command.HotKey, + // Hotkey - ctx may indicate a radio item hotkey was pressed. Beahvior depends on HasFocus + // If HasFocus and it's this.HotKey invoke Select command - DO NOT raise Accept + // If it's a radio item HotKey select that item and raise Seelcted event - DO NOT raise Accept + // If nothing is selected, select first and raise Selected event - DO NOT raise Accept + AddCommand (Command.HotKey, ctx => { var item = ctx.KeyBinding?.Context as int?; @@ -123,12 +128,7 @@ public class RadioGroup : View, IDesignable, IOrientation } // If a RadioItem.HotKey is pressed we always set the selected item - never SetFocus - if (ChangeSelectedItem (item.Value) == true) - { - return true; - } - - if (RaiseSelectEvent () == true) + if (ChangeSelectedItem (item.Value) && RaiseSelected () == true) { return true; } @@ -136,11 +136,16 @@ public class RadioGroup : View, IDesignable, IOrientation return false; } - if (SelectedItem == -1 && ChangeSelectedItem (0) == true) + if (SelectedItem == -1 && ChangeSelectedItem (0)) { - return true; + if (RaiseSelected () == true) + { + return true; + } + return false; } + // Default Command.Hotkey sets focus SetFocus (); return true; @@ -188,7 +193,7 @@ public class RadioGroup : View, IDesignable, IOrientation } /// - /// Gets or sets whether double clicking on a Radio Item will cause the event to be raised. + /// Gets or sets whether double clicking on a Radio Item will cause the event to be raised. /// /// /// @@ -220,7 +225,7 @@ public class RadioGroup : View, IDesignable, IOrientation if (c > -1) { - if (ChangeSelectedItem (c) == false) + if (ChangeSelectedItem (c)) { Cursor = c; e.Handled = true; @@ -233,7 +238,7 @@ public class RadioGroup : View, IDesignable, IOrientation { int savedSelectedItem = SelectedItem; - if (RaiseAcceptEvent () == true) + if (RaiseAccepted () == true) { e.Handled = false; _selected = savedSelectedItem; @@ -322,14 +327,13 @@ public class RadioGroup : View, IDesignable, IOrientation /// /// /// - /// if state change was canceled, if the state changed, and - /// if the state was not changed for some other reason. + /// if the selected item changed. /// - private bool? ChangeSelectedItem (int value) + private bool ChangeSelectedItem (int value) { if (_selected == value || value > _radioLabels.Count - 1) { - return null; + return false; } int savedSelected = _selected; @@ -341,7 +345,7 @@ public class RadioGroup : View, IDesignable, IOrientation SetNeedsDisplay (); - return false; + return true; } /// @@ -520,7 +524,17 @@ public class RadioGroup : View, IDesignable, IOrientation private void MoveEnd () { Cursor = Math.Max (_radioLabels.Count - 1, 0); } - private void MoveHome () { Cursor = 0; } + private bool MoveHome () + { + if (Cursor != 0) + { + Cursor = 0; + + return true; + } + + return false; + } private bool MoveUpLeft () { diff --git a/Terminal.Gui/Views/Shortcut.cs b/Terminal.Gui/Views/Shortcut.cs index 7ca9011fc..533427529 100644 --- a/Terminal.Gui/Views/Shortcut.cs +++ b/Terminal.Gui/Views/Shortcut.cs @@ -11,7 +11,7 @@ namespace Terminal.Gui; /// /// /// The following user actions will invoke the , causing the -/// event to be fired: +/// event to be fired: /// - Clicking on the . /// - Pressing the key specified by . /// - Pressing the HotKey specified by . @@ -91,7 +91,7 @@ public class Shortcut : View, IOrientation, IDesignable public Shortcut (Key key, string commandText, Action action, string helpText = null) { Id = "_shortcut"; - HighlightStyle = HighlightStyle.Pressed; + // Disabled for now due to bugs in highlight handling and mouse clicks - HighlightStyle = HighlightStyle.Pressed; CanFocus = true; Width = GetWidthDimAuto (); Height = Dim.Auto (DimAutoStyle.Content, 1); @@ -100,9 +100,26 @@ public class Shortcut : View, IOrientation, IDesignable _orientationHelper.OrientationChanging += (sender, e) => OrientationChanging?.Invoke (this, e); _orientationHelper.OrientationChanged += (sender, e) => OrientationChanged?.Invoke (this, e); - AddCommand (Command.HotKey, ctx => DispatchAcceptCommand (ctx)); + // Accept (Enter key) - AddCommand (Command.Accept, ctx => DispatchAcceptCommand (ctx)); - AddCommand (Command.Select, ctx => RaiseSelectEvent ()); + + // Hotkey - + AddCommand (Command.HotKey, ctx => + { + // The default HotKey handler sets Focus + SetFocus (); + + if (DispatchAcceptCommand (ctx) == true) + + { + return true; + } + + return RaiseSelected (); + }); + + // Select (Space key or click) - + AddCommand (Command.Select, ctx => RaiseSelected ()); TitleChanged += Shortcut_TitleChanged; // This needs to be set before CommandView is set @@ -128,8 +145,8 @@ public class Shortcut : View, IOrientation, IDesignable HelpView.MouseClick += HelpOrKeyView_MouseClick; KeyView.MouseClick += HelpOrKeyView_MouseClick; - HelpView.Select += HelpAndKeyViewOnSelect; - KeyView.Select += HelpAndKeyViewOnSelect; + HelpView.Selected += HelpAndKeyViewOnSelect; + KeyView.Selected += HelpAndKeyViewOnSelect; LayoutStarted += OnLayoutStarted; Initialized += OnInitialized; @@ -388,7 +405,7 @@ public class Shortcut : View, IOrientation, IDesignable { // If the subview (likely CommandView) didn't handle the mouse click, invoke the Select command. // e.Handled = CommandView.InvokeCommand (Command.Select) == true; - e.Handled = InvokeCommand (Command.Accept) == true; + e.Handled = InvokeCommand (Command.HotKey) == true; } //if (CanFocus) @@ -498,7 +515,7 @@ public class Shortcut : View, IOrientation, IDesignable if (_commandView is { }) { - _commandView.Accept -= CommandViewOnAccept; + _commandView.Accepted -= CommandViewOnSelected; Remove (_commandView); _commandView?.Dispose (); } @@ -523,11 +540,12 @@ public class Shortcut : View, IOrientation, IDesignable Title = _commandView.Text; - _commandView.Select += CommandViewOnAccept; + _commandView.Selected += CommandViewOnSelected; - void CommandViewOnAccept (object sender, HandledEventArgs e) + void CommandViewOnSelected (object sender, HandledEventArgs e) { - // Always eat CommandView.Accept + // Always eat CommandView.Select + SetFocus (); e.Handled = true; } @@ -535,12 +553,18 @@ public class Shortcut : View, IOrientation, IDesignable void CommandViewOnMouseClick (object sender, MouseEventEventArgs e) { - //if (!e.Handled) + if (!e.Handled) { - // If the subview (likely CommandView) didn't handle the mouse click, invoke the command. - InvokeCommand (Command.HotKey); + // If the subview (likely CommandView) didn't handle the mouse click, invoke the Accept Command. + InvokeCommand (Command.Accept); + + // Always eat the mouseclick e.Handled = true; } + + // Always Setfocus and invoke Select + SetFocus (); + InvokeCommand (Command.Select); } @@ -548,7 +572,7 @@ public class Shortcut : View, IOrientation, IDesignable SetHelpViewDefaultLayout (); SetKeyViewDefaultLayout (); ShowHide (); - UpdateKeyBinding (Key.Empty); + UpdateKeyBindings (Key.Empty); } } @@ -645,7 +669,7 @@ public class Shortcut : View, IOrientation, IDesignable Key oldKey = _key; _key = value; - UpdateKeyBinding (oldKey); + UpdateKeyBindings (oldKey); KeyView.Text = Key == Key.Empty ? string.Empty : $"{Key}"; ShowHide (); @@ -679,7 +703,7 @@ public class Shortcut : View, IOrientation, IDesignable _keyBindingScope = value; - UpdateKeyBinding (Key.Empty); + UpdateKeyBindings (Key.Empty); } } @@ -732,16 +756,20 @@ public class Shortcut : View, IOrientation, IDesignable HelpView.HighlightStyle = HighlightStyle.None; } - private void UpdateKeyBinding (Key oldKey) + private void UpdateKeyBindings (Key oldKey) { if (Key != null && Key.IsValid) { - // Disable the command view HotKey bindings - CommandView.KeyBindings.Remove (Key); - CommandView.KeyBindings.Remove (CommandView.HotKey); - CommandView.KeyBindings.Remove (CommandView.HotKey.WithShift); - CommandView.KeyBindings.Remove (CommandView.HotKey.WithAlt); - CommandView.KeyBindings.Remove (CommandView.HotKey.WithShift.WithAlt); + //// Disable the command view HotKey bindings + //IEnumerable list = CommandView.KeyBindings.GetKeysFromCommands (Command.HotKey); + //foreach (Key cmdViewKey in list) + //{ + // CommandView.KeyBindings.Remove (cmdViewKey); + // CommandView.KeyBindings.Remove (cmdViewKey.WithShift); + // CommandView.KeyBindings.Remove (cmdViewKey.WithAlt); + // CommandView.KeyBindings.Remove (cmdViewKey.WithShift.WithAlt); + // KeyBindings.Add (cmdViewKey, Command.HotKey); + //} if (KeyBindingScope.FastHasFlags (KeyBindingScope.Application)) { @@ -751,7 +779,7 @@ public class Shortcut : View, IOrientation, IDesignable } Application.KeyBindings.Remove (Key); - Application.KeyBindings.Add (Key, this, Command.Accept); + Application.KeyBindings.Add (Key, this, Command.HotKey); } else { @@ -761,7 +789,7 @@ public class Shortcut : View, IOrientation, IDesignable } KeyBindings.Remove (Key); - KeyBindings.Add (Key, KeyBindingScope | KeyBindingScope.HotKey, Command.Accept); + KeyBindings.Add (Key, KeyBindingScope | KeyBindingScope.HotKey, Command.HotKey); } } } @@ -778,18 +806,15 @@ public class Shortcut : View, IOrientation, IDesignable /// - if the user presses the HotKey specified by CommandView /// - if HasFocus and the user presses Space or Enter (or any other key bound to Command.Accept). /// - protected bool? DispatchAcceptCommand (CommandContext ctx) + internal bool? DispatchAcceptCommand (CommandContext ctx) { - if (RaiseSelectEvent () == true) - { - return true; - } - + // Invoke Select on the command view to cause it to change state if it wants to + // If this causes CommandView to raise Accept, we eat it CommandView.InvokeCommand (Command.Select); var cancel = false; - cancel = RaiseAcceptEvent () == true; + cancel = RaiseAccepted () == true; if (cancel is true) { @@ -809,7 +834,6 @@ public class Shortcut : View, IOrientation, IDesignable _targetView.InvokeCommand (_command); } - return cancel; } @@ -818,7 +842,7 @@ public class Shortcut : View, IOrientation, IDesignable /// mouse. /// /// - /// Note, the event is fired first, and if cancelled, the event will not be invoked. + /// Note, the event is fired first, and if cancelled, the event will not be invoked. /// [CanBeNull] public Action Action { get; set; } diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs index 127ff6629..f0b0ce4c5 100644 --- a/Terminal.Gui/Views/Slider.cs +++ b/Terminal.Gui/Views/Slider.cs @@ -1781,7 +1781,7 @@ public class Slider : View, IOrientation { SetFocusedOption (); - return RaiseAcceptEvent () == true; + return RaiseAccepted () == true; } internal bool MovePlus () diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs index 83675077e..1bb6b14ba 100644 --- a/Terminal.Gui/Views/StatusBar.cs +++ b/Terminal.Gui/Views/StatusBar.cs @@ -113,10 +113,10 @@ public class StatusBar : Bar, IDesignable Text = "I'll Hide", // Visible = false }; - button1.Accept += Button_Clicked; + button1.Accepted += Button_Clicked; Add (button1); - shortcut.Accept += (s, e) => + shortcut.Accepted += (s, e) => { button1.Visible = !button1.Visible; button1.Enabled = button1.Visible; @@ -134,7 +134,7 @@ public class StatusBar : Bar, IDesignable { Text = "Or me!", }; - button2.Accept += (s, e) => Application.RequestStop (); + button2.Accepted += (s, e) => Application.RequestStop (); Add (button2); diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index dd97f6571..4b54ccaf5 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -2513,7 +2513,7 @@ public class TextView : View // BUGBUG: AllowsReturn is mis-named. It should be EnterKeyAccepts. /// /// Gets or sets whether pressing ENTER in a creates a new line of text - /// in the view or invokes the event. + /// in the view or invokes the event. /// /// /// @@ -6047,7 +6047,7 @@ public class TextView : View { // By Default pressing ENTER should be ignored (OnAccept will return false or null). Only cancel if the // event was fired and set Cancel = true. - return RaiseAcceptEvent () is null or false; + return RaiseAccepted () is null or false; } SetWrapModel (); diff --git a/Terminal.Gui/Views/TreeView/TreeView.cs b/Terminal.Gui/Views/TreeView/TreeView.cs index a9c2464ec..31afcd62a 100644 --- a/Terminal.Gui/Views/TreeView/TreeView.cs +++ b/Terminal.Gui/Views/TreeView/TreeView.cs @@ -446,7 +446,7 @@ public class TreeView : View, ITreeView where T : class public bool? ActivateSelectedObjectIfAny () { // By default, Command.Accept calls OnAccept, so we need to call it here to ensure that the event is fired. - if (RaiseAcceptEvent () == true) + if (RaiseAccepted () == true) { return true; } diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index 0d6b5dd1e..3d78b27bf 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -85,8 +85,8 @@ public class Wizard : Dialog AddButton (BackButton); AddButton (NextFinishButton); - BackButton.Accept += BackBtn_Clicked; - NextFinishButton.Accept += NextfinishBtn_Clicked; + BackButton.Accepted += BackBtn_Clicked; + NextFinishButton.Accepted += NextfinishBtn_Clicked; Loaded += Wizard_Loaded; Closing += Wizard_Closing; diff --git a/UICatalog/KeyBindingsDialog.cs b/UICatalog/KeyBindingsDialog.cs index 1a9eec41d..fa2a2dc74 100644 --- a/UICatalog/KeyBindingsDialog.cs +++ b/UICatalog/KeyBindingsDialog.cs @@ -44,11 +44,11 @@ internal class KeyBindingsDialog : Dialog var btnChange = new Button { X = Pos.Percent (50), Y = 1, Text = "Ch_ange" }; Add (btnChange); - btnChange.Accept += RemapKey; + btnChange.Accepted += RemapKey; var close = new Button { Text = "Ok" }; - close.Accept += (s, e) => + close.Accepted += (s, e) => { Application.RequestStop (); ViewTracker.Instance.StartUsingNewKeyMap (CurrentBindings); @@ -56,7 +56,7 @@ internal class KeyBindingsDialog : Dialog AddButton (close); var cancel = new Button { Text = "Cancel" }; - cancel.Accept += (s, e) => Application.RequestStop (); + cancel.Accepted += (s, e) => Application.RequestStop (); AddButton (cancel); // Register event handler as the last thing in constructor to prevent early calls diff --git a/UICatalog/Scenarios/ASCIICustomButton.cs b/UICatalog/Scenarios/ASCIICustomButton.cs index 62442d8a7..cae55f17a 100644 --- a/UICatalog/Scenarios/ASCIICustomButton.cs +++ b/UICatalog/Scenarios/ASCIICustomButton.cs @@ -198,7 +198,7 @@ public class ASCIICustomButtonTest : Scenario Height = BUTTON_HEIGHT }; button.Initialized += Button_Initialized; - button.Accept += Button_Clicked; + button.Accepted += Button_Clicked; button.PointerEnter += Button_PointerEnter; button.MouseClick += Button_MouseClick; button.KeyDown += Button_KeyPress; @@ -216,7 +216,7 @@ public class ASCIICustomButtonTest : Scenario Height = BUTTON_HEIGHT }; closeButton.Initialized += Button_Initialized; - closeButton.Accept += Button_Clicked; + closeButton.Accepted += Button_Clicked; closeButton.PointerEnter += Button_PointerEnter; closeButton.MouseClick += Button_MouseClick; closeButton.KeyDown += Button_KeyPress; diff --git a/UICatalog/Scenarios/AdornmentEditor.cs b/UICatalog/Scenarios/AdornmentEditor.cs index 01fb05ccb..5c438cf17 100644 --- a/UICatalog/Scenarios/AdornmentEditor.cs +++ b/UICatalog/Scenarios/AdornmentEditor.cs @@ -146,7 +146,7 @@ public class AdornmentEditor : View Enabled = false }; - copyTop.Accept += (s, e) => + copyTop.Accepted += (s, e) => { AdornmentToEdit.Thickness = new (_topEdit.Value); _leftEdit.Value = _rightEdit.Value = _bottomEdit.Value = _topEdit.Value; diff --git a/UICatalog/Scenarios/Adornments.cs b/UICatalog/Scenarios/Adornments.cs index eed3a674a..5cba724b4 100644 --- a/UICatalog/Scenarios/Adornments.cs +++ b/UICatalog/Scenarios/Adornments.cs @@ -57,7 +57,7 @@ public class Adornments : Scenario var button = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "Press me!" }; - button.Accept += (s, e) => + button.Accepted += (s, e) => MessageBox.Query (20, 7, "Hi", $"Am I a {window.GetType ().Name}?", "Yes", "No"); var label = new TextView @@ -113,7 +113,7 @@ public class Adornments : Scenario Text = "some text", CanFocus = true }; - textFieldInPadding.Accept += (s, e) => MessageBox.Query (20, 7, "TextField", textFieldInPadding.Text, "Ok"); + textFieldInPadding.Accepted += (s, e) => MessageBox.Query (20, 7, "TextField", textFieldInPadding.Text, "Ok"); window.Padding.Add (textFieldInPadding); var btnButtonInPadding = new Button @@ -123,7 +123,7 @@ public class Adornments : Scenario Text = "_Button in Padding", CanFocus = true }; - btnButtonInPadding.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Button in Padding Pressed!", "Ok"); + btnButtonInPadding.Accepted += (s, e) => MessageBox.Query (20, 7, "Hi", "Button in Padding Pressed!", "Ok"); btnButtonInPadding.BorderStyle = LineStyle.Dashed; btnButtonInPadding.Border.Thickness = new (1, 1, 1, 1); window.Padding.Add (btnButtonInPadding); diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs index b744aae2f..1d6016d5c 100644 --- a/UICatalog/Scenarios/AllViewsTester.cs +++ b/UICatalog/Scenarios/AllViewsTester.cs @@ -160,7 +160,7 @@ public class AllViewsTester : Scenario _xRadioGroup.SelectedItemChanged += OnXRadioGroupOnSelectedItemChanged; _xText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" }; - _xText.Accept += (s, args) => + _xText.Accepted += (s, args) => { try { @@ -179,7 +179,7 @@ public class AllViewsTester : Scenario _locationFrame.Add (label); _yText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_yVal}" }; - _yText.Accept += (s, args) => + _yText.Accepted += (s, args) => { try { @@ -211,7 +211,7 @@ public class AllViewsTester : Scenario _wRadioGroup.SelectedItemChanged += OnWRadioGroupOnSelectedItemChanged; _wText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" }; - _wText.Accept += (s, args) => + _wText.Accepted += (s, args) => { try { @@ -242,7 +242,7 @@ public class AllViewsTester : Scenario _sizeFrame.Add (label); _hText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_hVal}" }; - _hText.Accept += (s, args) => + _hText.Accepted += (s, args) => { try { diff --git a/UICatalog/Scenarios/Bars.cs b/UICatalog/Scenarios/Bars.cs index 9d3e49189..9432dae9f 100644 --- a/UICatalog/Scenarios/Bars.cs +++ b/UICatalog/Scenarios/Bars.cs @@ -168,7 +168,7 @@ public class Bars : Scenario }; popOverMenu.Add (toggleShortcut); - popOverMenu.Accept += PopOverMenuOnAccept; + popOverMenu.Accepted += PopOverMenuOnAccept; void PopOverMenuOnAccept (object o, HandledEventArgs handledEventArgs) { @@ -255,7 +255,7 @@ public class Bars : Scenario { foreach (Shortcut sh in barView.Subviews.Where (s => s is Shortcut)!) { - sh.Accept += (o, args) => + sh.Accepted += (o, args) => { eventSource.Add ($"Accept: {sh!.SuperView.Id} {sh!.CommandView.Text}"); eventLog.MoveDown (); @@ -522,10 +522,10 @@ public class Bars : Scenario Text = "I'll Hide", // Visible = false }; - button1.Accept += Button_Clicked; + button1.Accepted += Button_Clicked; bar.Add (button1); - shortcut.Accept += (s, e) => + shortcut.Accepted += (s, e) => { button1.Visible = !button1.Visible; button1.Enabled = button1.Visible; @@ -543,7 +543,7 @@ public class Bars : Scenario { Text = "Or me!", }; - button2.Accept += (s, e) => Application.RequestStop (); + button2.Accepted += (s, e) => Application.RequestStop (); bar.Add (button2); diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs index 758a3df6e..5494b378e 100644 --- a/UICatalog/Scenarios/Buttons.cs +++ b/UICatalog/Scenarios/Buttons.cs @@ -36,7 +36,7 @@ public class Buttons : Scenario main.Add (defaultButton); // Note we handle Accept on main, not defaultButton - main.Accept += (s, e) => Application.RequestStop (); + main.Accepted += (s, e) => Application.RequestStop (); var swapButton = new Button { @@ -47,14 +47,14 @@ public class Buttons : Scenario ColorScheme = Colors.ColorSchemes ["Error"] }; - swapButton.Accept += (s, e) => + swapButton.Accepted += (s, e) => { e.Handled = !swapButton.IsDefault; defaultButton.IsDefault = !defaultButton.IsDefault; swapButton.IsDefault = !swapButton.IsDefault; }; - defaultButton.Accept += (s, e) => + defaultButton.Accepted += (s, e) => { e.Handled = !defaultButton.IsDefault; @@ -67,7 +67,7 @@ public class Buttons : Scenario static void DoMessage (Button button, string txt) { - button.Accept += (s, e) => + button.Accepted += (s, e) => { string btnText = button.Text; MessageBox.Query ("Message", $"Did you click {txt}?", "Yes", "No"); @@ -111,7 +111,7 @@ public class Buttons : Scenario main.Add ( button = new () { X = 2, Y = Pos.Bottom (button) + 1, Height = 2, Text = "a Newline\nin the button" } ); - button.Accept += (s, e) => + button.Accepted += (s, e) => { MessageBox.Query ("Message", "Question?", "Yes", "No"); e.Handled = true; @@ -119,7 +119,7 @@ public class Buttons : Scenario var textChanger = new Button { X = 2, Y = Pos.Bottom (button) + 1, Text = "Te_xt Changer" }; main.Add (textChanger); - textChanger.Accept += (s, e) => + textChanger.Accepted += (s, e) => { textChanger.Text += "!"; e.Handled = true; @@ -133,7 +133,7 @@ public class Buttons : Scenario Text = "Lets see if this will move as \"Text Changer\" grows" } ); - button.Accept += (sender, args) => { args.Handled = true; }; + button.Accepted += (sender, args) => { args.Handled = true; }; var removeButton = new Button { @@ -143,7 +143,7 @@ public class Buttons : Scenario main.Add (removeButton); // This in interesting test case because `moveBtn` and below are laid out relative to this one! - removeButton.Accept += (s, e) => + removeButton.Accepted += (s, e) => { removeButton.Visible = false; e.Handled = true; @@ -169,7 +169,7 @@ public class Buttons : Scenario Text = "Move This \u263b Button v_ia Pos" }; - moveBtn.Accept += (s, e) => + moveBtn.Accepted += (s, e) => { moveBtn.X = moveBtn.Frame.X + 5; e.Handled = true; @@ -186,7 +186,7 @@ public class Buttons : Scenario ColorScheme = Colors.ColorSchemes ["Error"], }; - sizeBtn.Accept += (s, e) => + sizeBtn.Accepted += (s, e) => { sizeBtn.Width = sizeBtn.Frame.Width + 5; e.Handled = true; @@ -206,7 +206,7 @@ public class Buttons : Scenario // Demonstrates how changing the View.Frame property can move Views var moveBtnA = new Button { ColorScheme = Colors.ColorSchemes ["Error"], Text = "Move This Button via Frame" }; - moveBtnA.Accept += (s, e) => + moveBtnA.Accepted += (s, e) => { moveBtnA.Frame = new ( moveBtnA.Frame.X + 5, @@ -224,7 +224,7 @@ public class Buttons : Scenario Y = 2, ColorScheme = Colors.ColorSchemes ["Error"], Text = " ~  s  gui.cs   master ↑_10 = Сохранить" }; - sizeBtnA.Accept += (s, e) => + sizeBtnA.Accepted += (s, e) => { sizeBtnA.Frame = new ( sizeBtnA.Frame.X, @@ -297,7 +297,7 @@ public class Buttons : Scenario ColorScheme = Colors.ColorSchemes ["TopLevel"], Text = mhkb }; - moveHotKeyBtn.Accept += (s, e) => + moveHotKeyBtn.Accepted += (s, e) => { moveHotKeyBtn.Text = MoveHotkey (moveHotKeyBtn.Text); e.Handled = true; @@ -314,7 +314,7 @@ public class Buttons : Scenario ColorScheme = Colors.ColorSchemes ["TopLevel"], Text = muhkb }; - moveUnicodeHotKeyBtn.Accept += (s, e) => + moveUnicodeHotKeyBtn.Accepted += (s, e) => { moveUnicodeHotKeyBtn.Text = MoveHotkey (moveUnicodeHotKeyBtn.Text); e.Handled = true; @@ -398,7 +398,7 @@ public class Buttons : Scenario Title = $"Accept Cou_nt: {noRepeatAcceptCount}", WantContinuousButtonPressed = false }; - noRepeatButton.Accept += (s, e) => + noRepeatButton.Accepted += (s, e) => { noRepeatButton.Title = $"Accept Cou_nt: {++noRepeatAcceptCount}"; e.Handled = true; @@ -420,7 +420,7 @@ public class Buttons : Scenario Title = $"Accept Co_unt: {acceptCount}", WantContinuousButtonPressed = true }; - repeatButton.Accept += (s, e) => + repeatButton.Accepted += (s, e) => { repeatButton.Title = $"Accept Co_unt: {++acceptCount}"; e.Handled = true; diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index 6c4b7080c..dd3cc01fb 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -77,7 +77,7 @@ public class CharacterMap : Scenario }; top.Add (_errorLabel); - jumpEdit.Accept += JumpEditOnAccept; + jumpEdit.Accepted += JumpEditOnAccept; _categoryList = new () { X = Pos.Right (_charMap), Y = Pos.Bottom (jumpLabel), Height = Dim.Fill () }; _categoryList.FullRowSelect = true; @@ -477,7 +477,7 @@ internal class CharMap : View ShadowStyle = ShadowStyle.None, CanFocus = false }; - up.Accept += (sender, args) => { args.Handled = ScrollVertical (-1) == true; }; + up.Accepted += (sender, args) => { args.Handled = ScrollVertical (-1) == true; }; var down = new Button { @@ -492,7 +492,7 @@ internal class CharMap : View ShadowStyle = ShadowStyle.None, CanFocus = false }; - down.Accept += (sender, args) => { ScrollVertical (1); }; + down.Accepted += (sender, args) => { ScrollVertical (1); }; var left = new Button { @@ -507,7 +507,7 @@ internal class CharMap : View ShadowStyle = ShadowStyle.None, CanFocus = false }; - left.Accept += (sender, args) => { ScrollHorizontal (-1); }; + left.Accepted += (sender, args) => { ScrollHorizontal (-1); }; var right = new Button { @@ -522,7 +522,7 @@ internal class CharMap : View ShadowStyle = ShadowStyle.None, CanFocus = false }; - right.Accept += (sender, args) => { ScrollHorizontal (1); }; + right.Accepted += (sender, args) => { ScrollHorizontal (1); }; Padding.Add (up, down, left, right); } @@ -1015,18 +1015,18 @@ internal class CharMap : View var dlg = new Dialog { Title = title, Buttons = [copyGlyph, copyCP, cancel] }; - copyGlyph.Accept += (s, a) => + copyGlyph.Accepted += (s, a) => { CopyGlyph (); dlg.RequestStop (); }; - copyCP.Accept += (s, a) => + copyCP.Accepted += (s, a) => { CopyCodePoint (); dlg.RequestStop (); }; - cancel.Accept += (s, a) => dlg.RequestStop (); + cancel.Accepted += (s, a) => dlg.RequestStop (); var rune = (Rune)SelectedCodePoint; var label = new Label { Text = "IsAscii: ", X = 0, Y = 0 }; diff --git a/UICatalog/Scenarios/ChineseUI.cs b/UICatalog/Scenarios/ChineseUI.cs index e94a98d09..a58cde062 100644 --- a/UICatalog/Scenarios/ChineseUI.cs +++ b/UICatalog/Scenarios/ChineseUI.cs @@ -31,7 +31,7 @@ public class ChineseUI : Scenario var btn = new Button { X = 1, Y = 1, Text = "你" }; // v1: A - btn.Accept += (s, e) => + btn.Accepted += (s, e) => { int result = MessageBox.Query ( "Confirm", diff --git a/UICatalog/Scenarios/Clipping.cs b/UICatalog/Scenarios/Clipping.cs index 58953f4da..218be567d 100644 --- a/UICatalog/Scenarios/Clipping.cs +++ b/UICatalog/Scenarios/Clipping.cs @@ -70,7 +70,7 @@ public class Clipping : Scenario }; var testButton = new Button { X = 2, Y = 2, Text = "click me" }; - testButton.Accept += (s, e) => { MessageBox.Query (10, 5, "Test", "test message", "Ok"); }; + testButton.Accepted += (s, e) => { MessageBox.Query (10, 5, "Test", "test message", "Ok"); }; embedded3.Add (testButton); embedded2.Add (embedded3); diff --git a/UICatalog/Scenarios/ComboBoxIteration.cs b/UICatalog/Scenarios/ComboBoxIteration.cs index 75d339681..c579a1260 100644 --- a/UICatalog/Scenarios/ComboBoxIteration.cs +++ b/UICatalog/Scenarios/ComboBoxIteration.cs @@ -60,7 +60,7 @@ public class ComboBoxIteration : Scenario var btnTwo = new Button { X = Pos.Right (comboBox) + 1, Text = "Two" }; - btnTwo.Accept += (s, e) => + btnTwo.Accepted += (s, e) => { items = ["one", "two"]; comboBox.SetSource (items); @@ -71,7 +71,7 @@ public class ComboBoxIteration : Scenario var btnThree = new Button { X = Pos.Right (comboBox) + 1, Y = Pos.Top (comboBox), Text = "Three" }; - btnThree.Accept += (s, e) => + btnThree.Accepted += (s, e) => { items =["one", "two", "three"]; comboBox.SetSource (items); diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index cb7a72130..9a0392d63 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -363,7 +363,7 @@ public class ComputedLayout : Scenario var anchorButton = new Button { Text = "Button using AnchorEnd", Y = Pos.AnchorEnd () }; anchorButton.X = Pos.AnchorEnd (); - anchorButton.Accept += (s, e) => + anchorButton.Accepted += (s, e) => { // This demonstrates how to have a dynamically sized button // Each time the button is clicked the button's text gets longer @@ -411,7 +411,7 @@ public class ComputedLayout : Scenario Y = Pos.AnchorEnd () - 1 }; - leftButton.Accept += (s, e) => + leftButton.Accepted += (s, e) => { // This demonstrates how to have a dynamically sized button // Each time the button is clicked the button's text gets longer @@ -429,7 +429,7 @@ public class ComputedLayout : Scenario Y = Pos.AnchorEnd (2), }; - centerButton.Accept += (s, e) => + centerButton.Accepted += (s, e) => { // This demonstrates how to have a dynamically sized button // Each time the button is clicked the button's text gets longer @@ -447,7 +447,7 @@ public class ComputedLayout : Scenario Y = Pos.Y (centerButton) }; - rightButton.Accept += (s, e) => + rightButton.Accepted += (s, e) => { // This demonstrates how to have a dynamically sized button // Each time the button is clicked the button's text gets longer diff --git a/UICatalog/Scenarios/ConfigurationEditor.cs b/UICatalog/Scenarios/ConfigurationEditor.cs index ac123217e..5bace1fad 100644 --- a/UICatalog/Scenarios/ConfigurationEditor.cs +++ b/UICatalog/Scenarios/ConfigurationEditor.cs @@ -70,7 +70,7 @@ public class ConfigurationEditor : Scenario Key = Key.F5.WithShift, Title = "Reload", }; - reloadShortcut.Accept += (s, e) => { Reload (); }; + reloadShortcut.Accepted += (s, e) => { Reload (); }; var saveShortcut = new Shortcut () { diff --git a/UICatalog/Scenarios/ContentScrolling.cs b/UICatalog/Scenarios/ContentScrolling.cs index 061612ef1..38ed73227 100644 --- a/UICatalog/Scenarios/ContentScrolling.cs +++ b/UICatalog/Scenarios/ContentScrolling.cs @@ -362,7 +362,7 @@ public class ContentScrolling : Scenario Height = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Percent (20)), }; - charMap.Accept += (s, e) => + charMap.Accepted += (s, e) => MessageBox.Query (20, 7, "Hi", $"Am I a {view.GetType ().Name}?", "Yes", "No"); var buttonAnchored = new Button diff --git a/UICatalog/Scenarios/CsvEditor.cs b/UICatalog/Scenarios/CsvEditor.cs index 29b655c38..42c48688c 100644 --- a/UICatalog/Scenarios/CsvEditor.cs +++ b/UICatalog/Scenarios/CsvEditor.cs @@ -304,13 +304,13 @@ public class CsvEditor : Scenario var ok = new Button { Text = "Ok", IsDefault = true }; - ok.Accept += (s, e) => + ok.Accepted += (s, e) => { okPressed = true; Application.RequestStop (); }; var cancel = new Button { Text = "Cancel" }; - cancel.Accept += (s, e) => { Application.RequestStop (); }; + cancel.Accepted += (s, e) => { Application.RequestStop (); }; var d = new Dialog { Title = title, Buttons = [ok, cancel] }; var lbl = new Label { X = 0, Y = 1, Text = label }; diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index bce23c433..292294d94 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -185,7 +185,7 @@ public class Dialogs : Scenario X = Pos.Center (), Y = Pos.Bottom (frame) + 2, IsDefault = true, Text = "_Show Dialog" }; - app.Accept += (s, e) => + app.Accepted += (s, e) => { Dialog dlg = CreateDemoDialog ( widthEdit, @@ -255,7 +255,7 @@ public class Dialogs : Scenario button = new () { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 }; } - button.Accept += (s, e) => + button.Accepted += (s, e) => { clicked = buttonId; Application.RequestStop (); @@ -290,7 +290,7 @@ public class Dialogs : Scenario Text = "_Add a button" }; - add.Accept += (s, e) => + add.Accepted += (s, e) => { int buttonId = buttons.Count; Button button; @@ -308,7 +308,7 @@ public class Dialogs : Scenario button = new () { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 }; } - button.Accept += (s, e) => + button.Accepted += (s, e) => { clicked = buttonId; Application.RequestStop (); @@ -330,7 +330,7 @@ public class Dialogs : Scenario Text = $"A_dd a {char.ConvertFromUtf32 (CODE_POINT)} to each button. This text is really long for a reason." }; - addChar.Accept += (s, e) => + addChar.Accepted += (s, e) => { foreach (Button button in buttons) { diff --git a/UICatalog/Scenarios/DimAutoDemo.cs b/UICatalog/Scenarios/DimAutoDemo.cs index 9b8efbc48..e57a859b4 100644 --- a/UICatalog/Scenarios/DimAutoDemo.cs +++ b/UICatalog/Scenarios/DimAutoDemo.cs @@ -156,7 +156,7 @@ public class DimAutoDemo : Scenario Y = Pos.AnchorEnd () }; - resetButton.Accept += (s, e) => + resetButton.Accepted += (s, e) => { //movingButton.Y = Pos.Bottom (hlabel); //movingButton.X = 0; diff --git a/UICatalog/Scenarios/DynamicMenuBar.cs b/UICatalog/Scenarios/DynamicMenuBar.cs index 20743c8d3..fc591ce1a 100644 --- a/UICatalog/Scenarios/DynamicMenuBar.cs +++ b/UICatalog/Scenarios/DynamicMenuBar.cs @@ -203,7 +203,7 @@ public class DynamicMenuBar : Scenario { X = Pos.X (lblShortcut), Y = Pos.Bottom (TextShortcutKey) + 1, Text = "Clear Shortcut" }; - btnShortcut.Accept += (s, e) => { TextShortcutKey.Text = ""; }; + btnShortcut.Accepted += (s, e) => { TextShortcutKey.Text = ""; }; Add (btnShortcut); CkbIsTopLevel.CheckedStateChanging += (s, e) => @@ -393,7 +393,7 @@ public class DynamicMenuBar : Scenario var btnOk = new Button { IsDefault = true, Text = "Ok" }; - btnOk.Accept += (s, e) => + btnOk.Accepted += (s, e) => { if (string.IsNullOrEmpty (TextTitle.Text)) { @@ -407,7 +407,7 @@ public class DynamicMenuBar : Scenario }; var btnCancel = new Button { Text = "Cancel" }; - btnCancel.Accept += (s, e) => + btnCancel.Accepted += (s, e) => { TextTitle.Text = string.Empty; Application.RequestStop (); @@ -666,7 +666,7 @@ public class DynamicMenuBar : Scenario }; Add (frmMenuDetails); - btnMenuBarUp.Accept += (s, e) => + btnMenuBarUp.Accepted += (s, e) => { int i = _currentSelectedMenuBar; @@ -688,7 +688,7 @@ public class DynamicMenuBar : Scenario } }; - btnMenuBarDown.Accept += (s, e) => + btnMenuBarDown.Accepted += (s, e) => { int i = _currentSelectedMenuBar; @@ -710,7 +710,7 @@ public class DynamicMenuBar : Scenario } }; - btnUp.Accept += (s, e) => + btnUp.Accepted += (s, e) => { int i = _lstMenus.SelectedItem; MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null; @@ -732,7 +732,7 @@ public class DynamicMenuBar : Scenario } }; - btnDown.Accept += (s, e) => + btnDown.Accepted += (s, e) => { int i = _lstMenus.SelectedItem; MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null; @@ -754,7 +754,7 @@ public class DynamicMenuBar : Scenario } }; - btnPreviowsParent.Accept += (s, e) => + btnPreviowsParent.Accepted += (s, e) => { if (_currentMenuBarItem != null && _currentMenuBarItem.Parent != null) { @@ -787,7 +787,7 @@ public class DynamicMenuBar : Scenario Add (btnOk); var btnCancel = new Button { X = Pos.Right (btnOk) + 3, Y = Pos.Top (btnOk), Text = "Cancel" }; - btnCancel.Accept += (s, e) => { SetFrameDetails (_currentEditMenuBarItem); }; + btnCancel.Accepted += (s, e) => { SetFrameDetails (_currentEditMenuBarItem); }; Add (btnCancel); txtDelimiter.TextChanging += (s, e) => @@ -813,7 +813,7 @@ public class DynamicMenuBar : Scenario _lstMenus.SelectedItemChanged += (s, e) => { SetFrameDetails (); }; - btnOk.Accept += (s, e) => + btnOk.Accepted += (s, e) => { if (string.IsNullOrEmpty (frmMenuDetails.TextTitle.Text) && _currentEditMenuBarItem != null) { @@ -840,7 +840,7 @@ public class DynamicMenuBar : Scenario } }; - btnAdd.Accept += (s, e) => + btnAdd.Accepted += (s, e) => { if (MenuBar == null) { @@ -883,7 +883,7 @@ public class DynamicMenuBar : Scenario } }; - btnRemove.Accept += (s, e) => + btnRemove.Accepted += (s, e) => { MenuItem menuItem = (DataContext.Menus.Count > 0 && _lstMenus.SelectedItem > -1 ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem @@ -951,7 +951,7 @@ public class DynamicMenuBar : Scenario SetFrameDetails (menuBarItem); }; - btnNext.Accept += (s, e) => + btnNext.Accepted += (s, e) => { if (_menuBar != null && _currentSelectedMenuBar + 1 < _menuBar.Menus.Length) { @@ -961,7 +961,7 @@ public class DynamicMenuBar : Scenario SelectCurrentMenuBarItem (); }; - btnPrevious.Accept += (s, e) => + btnPrevious.Accepted += (s, e) => { if (_currentSelectedMenuBar - 1 > -1) { @@ -980,7 +980,7 @@ public class DynamicMenuBar : Scenario } }; - btnAddMenuBar.Accept += (s, e) => + btnAddMenuBar.Accepted += (s, e) => { var frameDetails = new DynamicMenuBarDetails (null); DynamicMenuItem item = frameDetails.EnterMenuItem (); @@ -1015,7 +1015,7 @@ public class DynamicMenuBar : Scenario _menuBar.SetNeedsDisplay (); }; - btnRemoveMenuBar.Accept += (s, e) => + btnRemoveMenuBar.Accepted += (s, e) => { if (_menuBar == null) { diff --git a/UICatalog/Scenarios/DynamicStatusBar.cs b/UICatalog/Scenarios/DynamicStatusBar.cs index f9205257f..b0a8417cd 100644 --- a/UICatalog/Scenarios/DynamicStatusBar.cs +++ b/UICatalog/Scenarios/DynamicStatusBar.cs @@ -134,7 +134,7 @@ public class DynamicStatusBar : Scenario { X = Pos.X (_lblShortcut), Y = Pos.Bottom (TextShortcut) + 1, Text = "Clear Shortcut" }; - _btnShortcut.Accept += (s, e) => { TextShortcut.Text = ""; }; + _btnShortcut.Accepted += (s, e) => { TextShortcut.Text = ""; }; Add (_btnShortcut); } @@ -181,7 +181,7 @@ public class DynamicStatusBar : Scenario var btnOk = new Button { IsDefault = true, Text = "OK" }; - btnOk.Accept += (s, e) => + btnOk.Accepted += (s, e) => { if (string.IsNullOrEmpty (TextTitle.Text)) { @@ -196,7 +196,7 @@ public class DynamicStatusBar : Scenario }; var btnCancel = new Button { Text = "Cancel" }; - btnCancel.Accept += (s, e) => + btnCancel.Accepted += (s, e) => { TextTitle.Text = string.Empty; Application.RequestStop (); @@ -311,7 +311,7 @@ public class DynamicStatusBar : Scenario }; Add (_frmStatusBarDetails); - _btnUp.Accept += (s, e) => + _btnUp.Accepted += (s, e) => { int i = _lstItems.SelectedItem; Shortcut statusItem = DataContext.Items.Count > 0 ? DataContext.Items [i].Shortcut : null; @@ -334,7 +334,7 @@ public class DynamicStatusBar : Scenario } }; - _btnDown.Accept += (s, e) => + _btnDown.Accepted += (s, e) => { int i = _lstItems.SelectedItem; Shortcut statusItem = DataContext.Items.Count > 0 ? DataContext.Items [i].Shortcut : null; @@ -364,12 +364,12 @@ public class DynamicStatusBar : Scenario Add (_btnOk); var _btnCancel = new Button { X = Pos.Right (_btnOk) + 3, Y = Pos.Top (_btnOk), Text = "Cancel" }; - _btnCancel.Accept += (s, e) => { SetFrameDetails (_currentEditStatusItem); }; + _btnCancel.Accepted += (s, e) => { SetFrameDetails (_currentEditStatusItem); }; Add (_btnCancel); _lstItems.SelectedItemChanged += (s, e) => { SetFrameDetails (); }; - _btnOk.Accept += (s, e) => + _btnOk.Accepted += (s, e) => { if (string.IsNullOrEmpty (_frmStatusBarDetails.TextTitle.Text) && _currentEditStatusItem != null) { @@ -388,7 +388,7 @@ public class DynamicStatusBar : Scenario } }; - _btnAdd.Accept += (s, e) => + _btnAdd.Accepted += (s, e) => { if (StatusBar == null) { @@ -418,7 +418,7 @@ public class DynamicStatusBar : Scenario SetFrameDetails (); }; - _btnRemove.Accept += (s, e) => + _btnRemove.Accepted += (s, e) => { Shortcut statusItem = DataContext.Items.Count > 0 ? DataContext.Items [_lstItems.SelectedItem].Shortcut @@ -448,7 +448,7 @@ public class DynamicStatusBar : Scenario SetFrameDetails (statusItem); }; - _btnAddStatusBar.Accept += (s, e) => + _btnAddStatusBar.Accepted += (s, e) => { if (_statusBar != null) { @@ -459,7 +459,7 @@ public class DynamicStatusBar : Scenario Add (_statusBar); }; - _btnRemoveStatusBar.Accept += (s, e) => + _btnRemoveStatusBar.Accepted += (s, e) => { if (_statusBar == null) { diff --git a/UICatalog/Scenarios/Editor.cs b/UICatalog/Scenarios/Editor.cs index 65d250670..f5581b275 100644 --- a/UICatalog/Scenarios/Editor.cs +++ b/UICatalog/Scenarios/Editor.cs @@ -872,7 +872,7 @@ public class Editor : Scenario Text = "Find _Next" }; - btnFindNext.Accept += (s, e) => FindNext (); + btnFindNext.Accepted += (s, e) => FindNext (); d.Add (btnFindNext); var btnFindPrevious = new Button @@ -882,7 +882,7 @@ public class Editor : Scenario Enabled = !string.IsNullOrEmpty (txtToFind.Text), Text = "Find _Previous" }; - btnFindPrevious.Accept += (s, e) => FindPrevious (); + btnFindPrevious.Accepted += (s, e) => FindPrevious (); d.Add (btnFindPrevious); txtToFind.TextChanged += (s, e) => @@ -1099,7 +1099,7 @@ public class Editor : Scenario IsDefault = true, Text = "Replace _Next" }; - btnFindNext.Accept += (s, e) => ReplaceNext (); + btnFindNext.Accepted += (s, e) => ReplaceNext (); d.Add (btnFindNext); label = new () @@ -1129,7 +1129,7 @@ public class Editor : Scenario Enabled = !string.IsNullOrEmpty (txtToFind.Text), Text = "Replace _Previous" }; - btnFindPrevious.Accept += (s, e) => ReplacePrevious (); + btnFindPrevious.Accepted += (s, e) => ReplacePrevious (); d.Add (btnFindPrevious); var btnReplaceAll = new Button @@ -1139,7 +1139,7 @@ public class Editor : Scenario Enabled = !string.IsNullOrEmpty (txtToFind.Text), Text = "Replace _All" }; - btnReplaceAll.Accept += (s, e) => ReplaceAll (); + btnReplaceAll.Accepted += (s, e) => ReplaceAll (); d.Add (btnReplaceAll); txtToFind.TextChanged += (s, e) => diff --git a/UICatalog/Scenarios/FileDialogExamples.cs b/UICatalog/Scenarios/FileDialogExamples.cs index 094f210e7..069013b42 100644 --- a/UICatalog/Scenarios/FileDialogExamples.cs +++ b/UICatalog/Scenarios/FileDialogExamples.cs @@ -245,7 +245,7 @@ public class FileDialogExamples : Scenario private void SetupHandler (Button btn) { - btn.Accept += (s, e) => + btn.Accepted += (s, e) => { try { diff --git a/UICatalog/Scenarios/GraphViewExample.cs b/UICatalog/Scenarios/GraphViewExample.cs index 1b670ee44..41eadd2bb 100644 --- a/UICatalog/Scenarios/GraphViewExample.cs +++ b/UICatalog/Scenarios/GraphViewExample.cs @@ -185,7 +185,7 @@ public class GraphViewExample : Scenario CanFocus = false } }; - statusBar.Add (diagShortcut).Accept += DiagShortcut_Accept; + statusBar.Add (diagShortcut).Accepted += DiagShortcut_Accept; _graphs [_currentGraph++ % _graphs.Length] (); diff --git a/UICatalog/Scenarios/Images.cs b/UICatalog/Scenarios/Images.cs index 4faab9b8b..c48604c02 100644 --- a/UICatalog/Scenarios/Images.cs +++ b/UICatalog/Scenarios/Images.cs @@ -55,7 +55,7 @@ public class Images : Scenario }; win.Add (imageView); - btnOpenImage.Accept += (_, _) => + btnOpenImage.Accepted += (_, _) => { var ofd = new OpenDialog { Title = "Open Image", AllowsMultipleSelection = false }; Application.Run (ofd); diff --git a/UICatalog/Scenarios/InteractiveTree.cs b/UICatalog/Scenarios/InteractiveTree.cs index 1480969f9..595b3b994 100644 --- a/UICatalog/Scenarios/InteractiveTree.cs +++ b/UICatalog/Scenarios/InteractiveTree.cs @@ -82,13 +82,13 @@ public class InteractiveTree : Scenario var ok = new Button { Text = "Ok", IsDefault = true }; - ok.Accept += (s, e) => + ok.Accepted += (s, e) => { okPressed = true; Application.RequestStop (); }; var cancel = new Button { Text = "Cancel" }; - cancel.Accept += (s, e) => Application.RequestStop (); + cancel.Accepted += (s, e) => Application.RequestStop (); var d = new Dialog { Title = title, Buttons = [ok, cancel] }; var lbl = new Label { X = 0, Y = 1, Text = label }; diff --git a/UICatalog/Scenarios/InvertColors.cs b/UICatalog/Scenarios/InvertColors.cs index d88e627d4..f059aa434 100644 --- a/UICatalog/Scenarios/InvertColors.cs +++ b/UICatalog/Scenarios/InvertColors.cs @@ -36,7 +36,7 @@ public class InvertColors : Scenario var button = new Button { X = Pos.Center (), Y = foreColors.Length + 1, Text = "Invert color!" }; - button.Accept += (s, e) => + button.Accepted += (s, e) => { foreach (Label label in labels) { diff --git a/UICatalog/Scenarios/LineDrawing.cs b/UICatalog/Scenarios/LineDrawing.cs index 6302f386d..d43afbf09 100644 --- a/UICatalog/Scenarios/LineDrawing.cs +++ b/UICatalog/Scenarios/LineDrawing.cs @@ -147,7 +147,7 @@ public class LineDrawing : Scenario IsDefault = true }; - btnOk.Accept += (s, e) => + btnOk.Accepted += (s, e) => { accept = true; e.Handled = true; @@ -162,7 +162,7 @@ public class LineDrawing : Scenario Width = Dim.Auto () }; - btnCancel.Accept += (s, e) => + btnCancel.Accepted += (s, e) => { e.Handled = true; Application.RequestStop (); @@ -228,7 +228,7 @@ public class ToolsView : Window _addLayerBtn = new() { Text = "New Layer", X = Pos.Center (), Y = Pos.Bottom (_stylePicker) }; - _addLayerBtn.Accept += (s, a) => AddLayer?.Invoke (); + _addLayerBtn.Accepted += (s, a) => AddLayer?.Invoke (); Add (_colors, _stylePicker, _addLayerBtn); } diff --git a/UICatalog/Scenarios/ListColumns.cs b/UICatalog/Scenarios/ListColumns.cs index dc0433060..6f1d49eae 100644 --- a/UICatalog/Scenarios/ListColumns.cs +++ b/UICatalog/Scenarios/ListColumns.cs @@ -275,13 +275,13 @@ public class ListColumns : Scenario var accepted = false; var ok = new Button { Text = "Ok", IsDefault = true }; - ok.Accept += (s, e) => + ok.Accepted += (s, e) => { accepted = true; Application.RequestStop (); }; var cancel = new Button { Text = "Cancel" }; - cancel.Accept += (s, e) => { Application.RequestStop (); }; + cancel.Accepted += (s, e) => { Application.RequestStop (); }; var d = new Dialog { Title = prompt, Buttons = [ok, cancel] }; var tf = new TextField { Text = getter (_listColView).ToString (), X = 0, Y = 0, Width = Dim.Fill () }; diff --git a/UICatalog/Scenarios/ListViewWithSelection.cs b/UICatalog/Scenarios/ListViewWithSelection.cs index 2320ea64e..da6125a4d 100644 --- a/UICatalog/Scenarios/ListViewWithSelection.cs +++ b/UICatalog/Scenarios/ListViewWithSelection.cs @@ -139,8 +139,8 @@ public class ListViewWithSelection : Scenario _listView.SelectedItemChanged += (s, a) => LogEvent (s as View, a, "SelectedItemChanged"); _listView.OpenSelectedItem += (s, a) => LogEvent (s as View, a, "OpenSelectedItem"); _listView.CollectionChanged += (s, a) => LogEvent (s as View, a, "CollectionChanged"); - _listView.Accept += (s, a) => LogEvent (s as View, a, "Accept"); - _listView.Select += (s, a) => LogEvent (s as View, a, "Select"); + _listView.Accepted += (s, a) => LogEvent (s as View, a, "Accept"); + _listView.Selected += (s, a) => LogEvent (s as View, a, "Select"); bool? LogEvent (View sender, EventArgs args, string message) { diff --git a/UICatalog/Scenarios/ListsAndCombos.cs b/UICatalog/Scenarios/ListsAndCombos.cs index 8ea728a08..8baac6c71 100644 --- a/UICatalog/Scenarios/ListsAndCombos.cs +++ b/UICatalog/Scenarios/ListsAndCombos.cs @@ -147,13 +147,13 @@ public class ListsAndCombos : Scenario }; var btnMoveUp = new Button { X = 1, Y = Pos.Bottom (lbListView), Text = "Move _Up" }; - btnMoveUp.Accept += (s, e) => { listview.MoveUp (); }; + btnMoveUp.Accepted += (s, e) => { listview.MoveUp (); }; var btnMoveDown = new Button { X = Pos.Right (btnMoveUp) + 1, Y = Pos.Bottom (lbListView), Text = "Move _Down" }; - btnMoveDown.Accept += (s, e) => { listview.MoveDown (); }; + btnMoveDown.Accepted += (s, e) => { listview.MoveDown (); }; win.Add (btnMoveUp, btnMoveDown); diff --git a/UICatalog/Scenarios/Localization.cs b/UICatalog/Scenarios/Localization.cs index 08e01493d..a95a920d0 100644 --- a/UICatalog/Scenarios/Localization.cs +++ b/UICatalog/Scenarios/Localization.cs @@ -152,14 +152,14 @@ public class Localization : Scenario { X = Pos.Right (_allowAnyCheckBox) + 1, Y = Pos.Bottom (textAndFileDialogLabel) + 1, Text = "Open" }; - openDialogButton.Accept += (sender, e) => ShowFileDialog (false); + openDialogButton.Accepted += (sender, e) => ShowFileDialog (false); win.Add (openDialogButton); var saveDialogButton = new Button { X = Pos.Right (openDialogButton) + 1, Y = Pos.Bottom (textAndFileDialogLabel) + 1, Text = "Save" }; - saveDialogButton.Accept += (sender, e) => ShowFileDialog (true); + saveDialogButton.Accepted += (sender, e) => ShowFileDialog (true); win.Add (saveDialogButton); var wizardLabel = new Label @@ -173,7 +173,7 @@ public class Localization : Scenario win.Add (wizardLabel); var wizardButton = new Button { X = 2, Y = Pos.Bottom (wizardLabel) + 1, Text = "Open _wizard" }; - wizardButton.Accept += (sender, e) => ShowWizard (); + wizardButton.Accepted += (sender, e) => ShowWizard (); win.Add (wizardButton); win.Unloaded += (sender, e) => Quit (); diff --git a/UICatalog/Scenarios/MenuBarScenario.cs b/UICatalog/Scenarios/MenuBarScenario.cs index b9c6bee67..1a6065307 100644 --- a/UICatalog/Scenarios/MenuBarScenario.cs +++ b/UICatalog/Scenarios/MenuBarScenario.cs @@ -110,15 +110,15 @@ public class MenuBarScenario : Scenario menuBar.LayoutComplete += (s, e) => { _focusedView.Text = appWindow.MostFocused?.ToString () ?? "None"; }; var openBtn = new Button { X = Pos.Center (), Y = 4, Text = "_Open Menu", IsDefault = true }; - openBtn.Accept += (s, e) => { menuBar.OpenMenu (); }; + openBtn.Accepted += (s, e) => { menuBar.OpenMenu (); }; appWindow.Add (openBtn); var hideBtn = new Button { X = Pos.Center (), Y = Pos.Bottom (openBtn), Text = "Toggle Menu._Visible" }; - hideBtn.Accept += (s, e) => { menuBar.Visible = !menuBar.Visible; }; + hideBtn.Accepted += (s, e) => { menuBar.Visible = !menuBar.Visible; }; appWindow.Add (hideBtn); var enableBtn = new Button { X = Pos.Center (), Y = Pos.Bottom (hideBtn), Text = "_Toggle Menu.Enable" }; - enableBtn.Accept += (s, e) => { menuBar.Enabled = !menuBar.Enabled; }; + enableBtn.Accepted += (s, e) => { menuBar.Enabled = !menuBar.Enabled; }; appWindow.Add (enableBtn); appWindow.Add (menuBar); diff --git a/UICatalog/Scenarios/MessageBoxes.cs b/UICatalog/Scenarios/MessageBoxes.cs index e8c8f0e35..b1e53f358 100644 --- a/UICatalog/Scenarios/MessageBoxes.cs +++ b/UICatalog/Scenarios/MessageBoxes.cs @@ -228,7 +228,7 @@ public class MessageBoxes : Scenario X = Pos.Center (), Y = Pos.Bottom (frame) + 2, IsDefault = true, Text = "_Show MessageBox" }; - app.Accept += (s, e) => + app.Accepted += (s, e) => { try { diff --git a/UICatalog/Scenarios/Mouse.cs b/UICatalog/Scenarios/Mouse.cs index bec393232..988115e88 100644 --- a/UICatalog/Scenarios/Mouse.cs +++ b/UICatalog/Scenarios/Mouse.cs @@ -241,7 +241,7 @@ public class Mouse : Scenario }; win.Add (label, winLog); - clearButton.Accept += (s, e) => + clearButton.Accepted += (s, e) => { appLogList.Clear (); appLog.SetSource (appLogList); diff --git a/UICatalog/Scenarios/MultiColouredTable.cs b/UICatalog/Scenarios/MultiColouredTable.cs index 75ddb405d..ecacb1899 100644 --- a/UICatalog/Scenarios/MultiColouredTable.cs +++ b/UICatalog/Scenarios/MultiColouredTable.cs @@ -104,13 +104,13 @@ public class MultiColouredTable : Scenario var ok = new Button { Text = "Ok", IsDefault = true }; - ok.Accept += (s, e) => + ok.Accepted += (s, e) => { okPressed = true; Application.RequestStop (); }; var cancel = new Button { Text = "Cancel" }; - cancel.Accept += (s, e) => { Application.RequestStop (); }; + cancel.Accepted += (s, e) => { Application.RequestStop (); }; var d = new Dialog { Title = title, Buttons = [ok, cancel] }; var lbl = new Label { X = 0, Y = 1, Text = label }; diff --git a/UICatalog/Scenarios/NumericUpDownDemo.cs b/UICatalog/Scenarios/NumericUpDownDemo.cs index 3c17d7fcd..6d23714c7 100644 --- a/UICatalog/Scenarios/NumericUpDownDemo.cs +++ b/UICatalog/Scenarios/NumericUpDownDemo.cs @@ -114,7 +114,7 @@ internal class NumericUpDownEditor : View where T : notnull Width = 8, Title = "Value", }; - _value.Accept += ValuedOnAccept; + _value.Accepted += ValuedOnAccept; void ValuedOnAccept (object? sender, EventArgs e) { @@ -169,7 +169,7 @@ internal class NumericUpDownEditor : View where T : notnull Title = "Format", Width = Dim.Width (_value), }; - _format.Accept += FormatOnAccept; + _format.Accepted += FormatOnAccept; void FormatOnAccept (object? o, EventArgs eventArgs) { @@ -217,7 +217,7 @@ internal class NumericUpDownEditor : View where T : notnull Width = Dim.Width (_value), }; - _increment.Accept += IncrementOnAccept; + _increment.Accepted += IncrementOnAccept; void IncrementOnAccept (object? o, EventArgs eventArgs) { diff --git a/UICatalog/Scenarios/Progress.cs b/UICatalog/Scenarios/Progress.cs index 7bde12913..4a107172f 100644 --- a/UICatalog/Scenarios/Progress.cs +++ b/UICatalog/Scenarios/Progress.cs @@ -142,7 +142,7 @@ public class Progress : Scenario var startBoth = new Button { X = Pos.Center (), Y = Pos.Bottom (mainLoopTimeoutDemo) + 1, Text = "Start Both" }; - startBoth.Accept += (s, e) => + startBoth.Accepted += (s, e) => { systemTimerDemo.Start (); mainLoopTimeoutDemo.Start (); @@ -193,15 +193,15 @@ public class Progress : Scenario Add (LeftFrame); var startButton = new Button { X = Pos.Right (LeftFrame) + 1, Y = 0, Text = "Start Timer" }; - startButton.Accept += (s, e) => Start (); + startButton.Accepted += (s, e) => Start (); var pulseButton = new Button { X = Pos.Right (startButton) + 2, Y = Pos.Y (startButton), Text = "Pulse" }; - pulseButton.Accept += (s, e) => Pulse (); + pulseButton.Accepted += (s, e) => Pulse (); var stopbutton = new Button { X = Pos.Right (pulseButton) + 2, Y = Pos.Top (pulseButton), Text = "Stop Timer" }; - stopbutton.Accept += (s, e) => Stop (); + stopbutton.Accepted += (s, e) => Stop (); Add (startButton); Add (pulseButton); diff --git a/UICatalog/Scenarios/ProgressBarStyles.cs b/UICatalog/Scenarios/ProgressBarStyles.cs index 54855ce52..a6f07a737 100644 --- a/UICatalog/Scenarios/ProgressBarStyles.cs +++ b/UICatalog/Scenarios/ProgressBarStyles.cs @@ -72,7 +72,7 @@ public class ProgressBarStyles : Scenario }; container.Add (fgColorPickerBtn); - fgColorPickerBtn.Accept += (s, e) => + fgColorPickerBtn.Accepted += (s, e) => { if (!LineDrawing.PromptForColor ( fgColorPickerBtn.Text, @@ -102,7 +102,7 @@ public class ProgressBarStyles : Scenario }; container.Add (bgColorPickerBtn); - bgColorPickerBtn.Accept += (s, e) => + bgColorPickerBtn.Accepted += (s, e) => { if (!LineDrawing.PromptForColor ( fgColorPickerBtn.Text, @@ -172,7 +172,7 @@ public class ProgressBarStyles : Scenario }; container.Add (continuousPB); - button.Accept += (s, e) => + button.Accepted += (s, e) => { if (_fractionTimer == null) { diff --git a/UICatalog/Scenarios/RunTExample.cs b/UICatalog/Scenarios/RunTExample.cs index b949718be..6e6883d76 100644 --- a/UICatalog/Scenarios/RunTExample.cs +++ b/UICatalog/Scenarios/RunTExample.cs @@ -61,7 +61,7 @@ public class RunTExample : Scenario }; // When login button is clicked display a message popup - btnLogin.Accept += (s, e) => + btnLogin.Accepted += (s, e) => { if (_usernameText.Text == "admin" && passwordText.Text == "password") { diff --git a/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs b/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs index 97c15c5a9..906f906fa 100644 --- a/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs +++ b/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs @@ -106,7 +106,7 @@ public class RuneWidthGreaterThanOne : Scenario _label.Text = "Enter your name 你:"; _text.Text = "gui.cs 你:"; _button.Text = "Say Hello 你"; - _button.Accept += MixedMessage; + _button.Accepted += MixedMessage; _labelR.X = Pos.AnchorEnd (21); _labelR.Y = 18; _labelR.Text = "This is a test text 你"; @@ -126,7 +126,7 @@ public class RuneWidthGreaterThanOne : Scenario _label.Text = "Enter your name:"; _text.Text = "gui.cs"; _button.Text = "Say Hello"; - _button.Accept += NarrowMessage; + _button.Accepted += NarrowMessage; _labelR.X = Pos.AnchorEnd (19); _labelR.Y = 18; _labelR.Text = "This is a test text"; @@ -143,15 +143,15 @@ public class RuneWidthGreaterThanOne : Scenario switch (_lastRunesUsed) { case "Narrow": - _button.Accept -= NarrowMessage; + _button.Accepted -= NarrowMessage; break; case "Mixed": - _button.Accept -= MixedMessage; + _button.Accepted -= MixedMessage; break; case "Wide": - _button.Accept -= WideMessage; + _button.Accepted -= WideMessage; break; } @@ -165,7 +165,7 @@ public class RuneWidthGreaterThanOne : Scenario _label.Text = "あなたの名前を入力してください:"; _text.Text = "ティラミス"; _button.Text = "こんにちはと言う"; - _button.Accept += WideMessage; + _button.Accepted += WideMessage; _labelR.X = Pos.AnchorEnd (29); _labelR.Y = 18; _labelR.Text = "あなたの名前を入力してください"; diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs index 125b7e3bc..042551f4c 100644 --- a/UICatalog/Scenarios/Scrolling.cs +++ b/UICatalog/Scenarios/Scrolling.cs @@ -77,7 +77,7 @@ public class Scrolling : Scenario scrollView.Add (verticalRuler); var pressMeButton = new Button { X = 3, Y = 3, Text = "Press me!" }; - pressMeButton.Accept += (s, e) => MessageBox.Query (20, 7, "MessageBox", "Neat?", "Yes", "No"); + pressMeButton.Accepted += (s, e) => MessageBox.Query (20, 7, "MessageBox", "Neat?", "Yes", "No"); scrollView.Add (pressMeButton); var aLongButton = new Button @@ -88,7 +88,7 @@ public class Scrolling : Scenario Width = Dim.Fill (3), Text = "A very long button. Should be wide enough to demo clipping!" }; - aLongButton.Accept += (s, e) => MessageBox.Query (20, 7, "MessageBox", "Neat?", "Yes", "No"); + aLongButton.Accepted += (s, e) => MessageBox.Query (20, 7, "MessageBox", "Neat?", "Yes", "No"); scrollView.Add (aLongButton); scrollView.Add ( @@ -130,7 +130,7 @@ public class Scrolling : Scenario // TODO: Use Pos.Width instead of (Right-Left) when implemented (#502) anchorButton.X = Pos.AnchorEnd (0) - (Pos.Right (anchorButton) - Pos.Left (anchorButton)); - anchorButton.Accept += (s, e) => + anchorButton.Accepted += (s, e) => { // This demonstrates how to have a dynamically sized button // Each time the button is clicked the button's text gets longer diff --git a/UICatalog/Scenarios/SendKeys.cs b/UICatalog/Scenarios/SendKeys.cs index 2ac87f67b..9ba9cf0e9 100644 --- a/UICatalog/Scenarios/SendKeys.cs +++ b/UICatalog/Scenarios/SendKeys.cs @@ -100,7 +100,7 @@ public class SendKeys : Scenario txtInput.SetFocus (); } - button.Accept += (s, e) => ProcessInput (); + button.Accepted += (s, e) => ProcessInput (); win.KeyDown += (s, e) => { diff --git a/UICatalog/Scenarios/Shortcuts.cs b/UICatalog/Scenarios/Shortcuts.cs index 955ba15ed..1564cca9e 100644 --- a/UICatalog/Scenarios/Shortcuts.cs +++ b/UICatalog/Scenarios/Shortcuts.cs @@ -146,7 +146,7 @@ public class Shortcuts : Scenario KeyBindingScope = KeyBindingScope.HotKey, }; Button button = (Button)vShortcut4.CommandView; - vShortcut4.Accept += Button_Clicked; + vShortcut4.Accepted += Button_Clicked; Application.Top.Add (vShortcut4); @@ -343,7 +343,7 @@ public class Shortcuts : Scenario HelpText = "App Scope", CanFocus = false }; - hShortcut3.Accept += (o, args) => + hShortcut3.Accepted += (o, args) => { Application.RequestStop (); }; @@ -354,27 +354,28 @@ public class Shortcuts : Scenario { if (sh is Shortcut shortcut) { - shortcut.Select += (o, args) => + shortcut.Selected += (o, args) => { eventSource.Add ($"{shortcut!.Id}.Select: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}"); eventLog.MoveDown (); //args.Handled = true; }; - shortcut.CommandView.Select += (o, args) => + shortcut.CommandView.Selected += (o, args) => { eventSource.Add ($"{shortcut!.Id}.CommandView.Select: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}"); eventLog.MoveDown (); }; - shortcut.Accept += (o, args) => + shortcut.Accepted += (o, args) => { eventSource.Add ($"{shortcut!.Id}.Accept: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}"); eventLog.MoveDown (); + // We don't want this to exit the Scenario args.Handled = true; }; - shortcut.CommandView.Accept += (o, args) => + shortcut.CommandView.Accepted += (o, args) => { eventSource.Add ($"{shortcut!.Id}.CommandView.Accept: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}"); eventLog.MoveDown (); diff --git a/UICatalog/Scenarios/SingleBackgroundWorker.cs b/UICatalog/Scenarios/SingleBackgroundWorker.cs index ae756645e..9e3bdea9d 100644 --- a/UICatalog/Scenarios/SingleBackgroundWorker.cs +++ b/UICatalog/Scenarios/SingleBackgroundWorker.cs @@ -91,7 +91,7 @@ public class SingleBackgroundWorker : Scenario var cancel = new Button { Text = "Cancel Worker" }; - cancel.Accept += (s, e) => + cancel.Accepted += (s, e) => { if (_worker == null) { diff --git a/UICatalog/Scenarios/Sliders.cs b/UICatalog/Scenarios/Sliders.cs index dfab8aa12..47b146124 100644 --- a/UICatalog/Scenarios/Sliders.cs +++ b/UICatalog/Scenarios/Sliders.cs @@ -595,7 +595,7 @@ public class Sliders : Scenario foreach (Slider slider in app.Subviews.Where (v => v is Slider)!) { - slider.Accept += (o, args) => + slider.Accepted += (o, args) => { eventSource.Add ($"Accept: {string.Join(",", slider.GetSetOptions ())}"); eventLog.MoveDown (); diff --git a/UICatalog/Scenarios/TableEditor.cs b/UICatalog/Scenarios/TableEditor.cs index 677d5fe35..a9cd4ad0a 100644 --- a/UICatalog/Scenarios/TableEditor.cs +++ b/UICatalog/Scenarios/TableEditor.cs @@ -878,13 +878,13 @@ public class TableEditor : Scenario var ok = new Button { Text = "Ok", IsDefault = true }; - ok.Accept += (s, e) => + ok.Accepted += (s, e) => { okPressed = true; Application.RequestStop (); }; var cancel = new Button { Text = "Cancel" }; - cancel.Accept += (s, e) => { Application.RequestStop (); }; + cancel.Accepted += (s, e) => { Application.RequestStop (); }; var d = new Dialog { Title = title, Buttons = [ok, cancel] }; var lbl = new Label { X = 0, Y = 1, Text = _tableView.Table.ColumnNames [e.Col] }; @@ -1076,13 +1076,13 @@ public class TableEditor : Scenario var accepted = false; var ok = new Button { Text = "Ok", IsDefault = true }; - ok.Accept += (s, e) => + ok.Accepted += (s, e) => { accepted = true; Application.RequestStop (); }; var cancel = new Button { Text = "Cancel" }; - cancel.Accept += (s, e) => { Application.RequestStop (); }; + cancel.Accepted += (s, e) => { Application.RequestStop (); }; var d = new Dialog { Title = prompt, diff --git a/UICatalog/Scenarios/Text.cs b/UICatalog/Scenarios/Text.cs index 574f9866f..4ca74e746 100644 --- a/UICatalog/Scenarios/Text.cs +++ b/UICatalog/Scenarios/Text.cs @@ -442,7 +442,7 @@ public class Text : Scenario win.Add (acceptView); - win.Accept += WinOnAccept; + win.Accepted += WinOnAccept; Application.Run (win); win.Dispose (); diff --git a/UICatalog/Scenarios/Threading.cs b/UICatalog/Scenarios/Threading.cs index 9e8e3e168..a50aa2618 100644 --- a/UICatalog/Scenarios/Threading.cs +++ b/UICatalog/Scenarios/Threading.cs @@ -56,7 +56,7 @@ public class Threading : Scenario }; _btnActionCancel = new Button { X = 1, Y = 1, Text = "Cancelable Load Items" }; - _btnActionCancel.Accept += (s, e) => Application.Invoke (CallLoadItemsAsync); + _btnActionCancel.Accepted += (s, e) => Application.Invoke (CallLoadItemsAsync); win.Add (new Label { X = Pos.X (_btnActionCancel), Y = Pos.Y (_btnActionCancel) + 4, Text = "Data Items:" }); @@ -84,24 +84,24 @@ public class Threading : Scenario var text = new TextField { X = 1, Y = 3, Width = 100, Text = "Type anything after press the button" }; var btnAction = new Button { X = 80, Y = 10, Text = "Load Data Action" }; - btnAction.Accept += (s, e) => _action.Invoke (); + btnAction.Accepted += (s, e) => _action.Invoke (); var btnLambda = new Button { X = 80, Y = 12, Text = "Load Data Lambda" }; - btnLambda.Accept += (s, e) => _lambda.Invoke (); + btnLambda.Accepted += (s, e) => _lambda.Invoke (); var btnHandler = new Button { X = 80, Y = 14, Text = "Load Data Handler" }; - btnHandler.Accept += (s, e) => _handler.Invoke (null, EventArgs.Empty); + btnHandler.Accepted += (s, e) => _handler.Invoke (null, EventArgs.Empty); var btnSync = new Button { X = 80, Y = 16, Text = "Load Data Synchronous" }; - btnSync.Accept += (s, e) => _sync.Invoke (); + btnSync.Accepted += (s, e) => _sync.Invoke (); var btnMethod = new Button { X = 80, Y = 18, Text = "Load Data Method" }; - btnMethod.Accept += async (s, e) => await MethodAsync (); + btnMethod.Accepted += async (s, e) => await MethodAsync (); var btnClearData = new Button { X = 80, Y = 20, Text = "Clear Data" }; - btnClearData.Accept += (s, e) => + btnClearData.Accepted += (s, e) => { _itemsList.Source = null; LogJob ("Cleaning Data"); }; var btnQuit = new Button { X = 80, Y = 22, Text = "Quit" }; - btnQuit.Accept += (s, e) => Application.RequestStop (); + btnQuit.Accepted += (s, e) => Application.RequestStop (); win.Add ( _itemsList, diff --git a/UICatalog/Scenarios/TimeAndDate.cs b/UICatalog/Scenarios/TimeAndDate.cs index 6fe0a4d82..27f70e58b 100644 --- a/UICatalog/Scenarios/TimeAndDate.cs +++ b/UICatalog/Scenarios/TimeAndDate.cs @@ -126,7 +126,7 @@ public class TimeAndDate : Scenario X = Pos.Center (), Y = Pos.Bottom (win) - 5, Text = "Swap Long/Short & Read/Read Only" }; - swapButton.Accept += (s, e) => + swapButton.Accepted += (s, e) => { longTime.ReadOnly = !longTime.ReadOnly; shortTime.ReadOnly = !shortTime.ReadOnly; diff --git a/UICatalog/Scenarios/VkeyPacketSimulator.cs b/UICatalog/Scenarios/VkeyPacketSimulator.cs index 66e826743..d8562a697 100644 --- a/UICatalog/Scenarios/VkeyPacketSimulator.cs +++ b/UICatalog/Scenarios/VkeyPacketSimulator.cs @@ -244,7 +244,7 @@ public class VkeyPacketSimulator : Scenario } }; - btnInput.Accept += (s, e) => + btnInput.Accepted += (s, e) => { if (!tvInput.HasFocus && _keyboardStrokes.Count == 0) { @@ -252,7 +252,7 @@ public class VkeyPacketSimulator : Scenario } }; - btnOutput.Accept += (s, e) => + btnOutput.Accepted += (s, e) => { if (!tvOutput.HasFocus && _keyboardStrokes.Count == 0) { diff --git a/UICatalog/Scenarios/WindowsAndFrameViews.cs b/UICatalog/Scenarios/WindowsAndFrameViews.cs index 34b8dfe6f..af351c4e5 100644 --- a/UICatalog/Scenarios/WindowsAndFrameViews.cs +++ b/UICatalog/Scenarios/WindowsAndFrameViews.cs @@ -52,7 +52,7 @@ public class WindowsAndFrameViews : Scenario ColorScheme = Colors.ColorSchemes ["Error"], Text = $"Padding of container is {padding}" }; - paddingButton.Accept += (s, e) => About (); + paddingButton.Accepted += (s, e) => About (); win.Add (paddingButton); win.Add ( @@ -97,7 +97,7 @@ public class WindowsAndFrameViews : Scenario X = Pos.Center (), Y = 0, ColorScheme = Colors.ColorSchemes ["Error"], Text = "Press me! (Y = 0)" }; - pressMeButton.Accept += (s, e) => + pressMeButton.Accepted += (s, e) => MessageBox.ErrorQuery (loopWin.Title, "Neat?", "Yes", "No"); loopWin.Add (pressMeButton); diff --git a/UICatalog/Scenarios/WizardAsView.cs b/UICatalog/Scenarios/WizardAsView.cs index cb7a768bb..f19730ab6 100644 --- a/UICatalog/Scenarios/WizardAsView.cs +++ b/UICatalog/Scenarios/WizardAsView.cs @@ -122,7 +122,7 @@ public class WizardAsView : Scenario Text = "Press Me to Rename Step", X = Pos.Right (buttonLbl), Y = Pos.Top (buttonLbl) }; - button.Accept += (s, e) => + button.Accepted += (s, e) => { secondStep.Title = "2nd Step"; diff --git a/UICatalog/Scenarios/Wizards.cs b/UICatalog/Scenarios/Wizards.cs index e018b0f42..c3b49f047 100644 --- a/UICatalog/Scenarios/Wizards.cs +++ b/UICatalog/Scenarios/Wizards.cs @@ -109,7 +109,7 @@ public class Wizards : Scenario X = Pos.Center (), Y = Pos.Bottom (frame) + 2, IsDefault = true, Text = "_Show Wizard" }; - showWizardButton.Accept += (s, e) => + showWizardButton.Accepted += (s, e) => { try { @@ -193,7 +193,7 @@ public class Wizards : Scenario }; secondStep.Add (radioGroup2); - button.Accept += (s, e) => + button.Accepted += (s, e) => { secondStep.Title = "2nd Step"; @@ -299,7 +299,7 @@ public class Wizards : Scenario Y = Pos.AnchorEnd () }; - hideHelpBtn.Accept += (s, e) => + hideHelpBtn.Accepted += (s, e) => { if (fourthStep.HelpText.Length > 0) { diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index 9c38310f3..99a71a00b 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -515,7 +515,7 @@ public class UICatalogApp Title = "Show/Hide Status Bar", CanFocus = false, }; - statusBarShortcut.Accept += (sender, args) => + statusBarShortcut.Accepted += (sender, args) => { StatusBar.Visible = !StatusBar.Visible; args.Handled = true; diff --git a/UnitTests/Application/MainLoopTests.cs b/UnitTests/Application/MainLoopTests.cs index 7dc4f122f..8b5b45fc6 100644 --- a/UnitTests/Application/MainLoopTests.cs +++ b/UnitTests/Application/MainLoopTests.cs @@ -682,7 +682,7 @@ public class MainLoopTests var btnLaunch = new Button { Text = "Open Window" }; - btnLaunch.Accept += (s, e) => action (); + btnLaunch.Accepted += (s, e) => action (); var top = new Toplevel (); top.Add (btnLaunch); @@ -918,11 +918,11 @@ public class MainLoopTests btn = new Button { Text = "Click Me" }; - btn.Accept += RunAsyncTest; + btn.Accepted += RunAsyncTest; var totalbtn = new Button { X = Pos.Right (btn), Text = "total" }; - totalbtn.Accept += (s, e) => { MessageBox.Query ("Count", $"Count is {total}", "Ok"); }; + totalbtn.Accepted += (s, e) => { MessageBox.Query ("Count", $"Count is {total}", "Ok"); }; startWindow.Add (btn); startWindow.Add (totalbtn); diff --git a/UnitTests/Dialogs/DialogTests.cs b/UnitTests/Dialogs/DialogTests.cs index ca272cdcb..53b06b060 100644 --- a/UnitTests/Dialogs/DialogTests.cs +++ b/UnitTests/Dialogs/DialogTests.cs @@ -1058,18 +1058,18 @@ public class DialogTests Button btn3 = null; string expected = null; - btn1.Accept += (s, e) => + btn1.Accepted += (s, e) => { btn2 = new () { Text = "Show Sub" }; btn3 = new () { Text = "Close" }; - btn3.Accept += (s, e) => RequestStop (); + btn3.Accepted += (s, e) => RequestStop (); - btn2.Accept += (s, e) => + btn2.Accepted += (s, e) => { // Don't test MessageBox in Dialog unit tests! var subBtn = new Button { Text = "Ok", IsDefault = true }; var subDlg = new Dialog { Text = "ya", Width = 20, Height = 5, Buttons = [subBtn] }; - subBtn.Accept += (s, e) => RequestStop (subDlg); + subBtn.Accepted += (s, e) => RequestStop (subDlg); Run (subDlg); }; diff --git a/UnitTests/Dialogs/MessageBoxTests.cs b/UnitTests/Dialogs/MessageBoxTests.cs index e5ab51578..105d3cb78 100644 --- a/UnitTests/Dialogs/MessageBoxTests.cs +++ b/UnitTests/Dialogs/MessageBoxTests.cs @@ -37,7 +37,7 @@ public class MessageBoxTests Button btn = Application.Navigation!.GetFocused () as Button; - btn.Accept += (sender, e) => { btnAcceptCount++; }; + btn.Accepted += (sender, e) => { btnAcceptCount++; }; // Click Application.OnKeyDown (Key.Enter); @@ -120,7 +120,7 @@ public class MessageBoxTests Button btn = Application.Navigation!.GetFocused () as Button; - btn.Accept += (sender, e) => { btnAcceptCount++; }; + btn.Accepted += (sender, e) => { btnAcceptCount++; }; Application.OnKeyDown (Key.Space); diff --git a/UnitTests/TestHelpers.cs b/UnitTests/TestHelpers.cs index 88224d8e3..d13924150 100644 --- a/UnitTests/TestHelpers.cs +++ b/UnitTests/TestHelpers.cs @@ -100,6 +100,10 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute } } + // Reset to defaults + Locations = ConfigLocations.DefaultOnly; + Reset(); + // Enable subsequent tests that call Init to get all config files (the default). Locations = ConfigLocations.All; } diff --git a/UnitTests/View/HotKeyTests.cs b/UnitTests/View/HotKeyTests.cs index 328515ffc..f5736ff6f 100644 --- a/UnitTests/View/HotKeyTests.cs +++ b/UnitTests/View/HotKeyTests.cs @@ -357,9 +357,9 @@ public class HotKeyTests Title = "_Test" }; Application.Top.Add (view); - view.HotKeyCommand += (s, e) => hotKeyRaised = true; - view.Accept += (s, e) => acceptRaised = true; - view.Select += (s, e) => selectRaised = true; + view.HotKeyHandled += (s, e) => hotKeyRaised = true; + view.Accepted += (s, e) => acceptRaised = true; + view.Selected += (s, e) => selectRaised = true; Assert.Equal (KeyCode.T, view.HotKey); Assert.False (Application.OnKeyDown (Key.T)); // wasn't handled diff --git a/UnitTests/View/Navigation/EnabledTests.cs b/UnitTests/View/Navigation/EnabledTests.cs index 24bb0c206..f44b847ec 100644 --- a/UnitTests/View/Navigation/EnabledTests.cs +++ b/UnitTests/View/Navigation/EnabledTests.cs @@ -258,7 +258,7 @@ public class EnabledTests () : TestsAllViews var wasClicked = false; var button = new Button { Text = "Click Me" }; button.IsDefault = true; - button.Accept += (s, e) => wasClicked = !wasClicked; + button.Accepted += (s, e) => wasClicked = !wasClicked; var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () }; win.Add (button); var top = new Toplevel (); diff --git a/UnitTests/View/Navigation/HasFocusTests.cs b/UnitTests/View/Navigation/HasFocusTests.cs index 258c408e9..d54296617 100644 --- a/UnitTests/View/Navigation/HasFocusTests.cs +++ b/UnitTests/View/Navigation/HasFocusTests.cs @@ -80,7 +80,7 @@ public class HasFocusTests () : TestsAllViews { var wasClicked = false; var view = new Button { Text = "Click Me" }; - view.Accept += (s, e) => wasClicked = !wasClicked; + view.Accepted += (s, e) => wasClicked = !wasClicked; view.NewKeyDownEvent (Key.Space); Assert.True (wasClicked); diff --git a/UnitTests/View/ViewCommandTests.cs b/UnitTests/View/ViewCommandTests.cs index 937443e24..caea1b273 100644 --- a/UnitTests/View/ViewCommandTests.cs +++ b/UnitTests/View/ViewCommandTests.cs @@ -42,7 +42,7 @@ public class ViewCommandTests (ITestOutputHelper output) var view = new View (); var acceptInvoked = false; - view.Accept += ViewOnAccept; + view.Accepted += ViewOnAccept; bool? ret = view.InvokeCommand (Command.Accept); Assert.True (ret); @@ -63,7 +63,7 @@ public class ViewCommandTests (ITestOutputHelper output) var view = new View (); var accepted = false; - view.Accept += ViewOnAccept; + view.Accepted += ViewOnAccept; view.InvokeCommand (Command.Accept); Assert.True (accepted); @@ -130,19 +130,26 @@ public class ViewCommandTests (ITestOutputHelper output) #endregion OnAccept/Accept tests #region OnSelect/Select tests - [Fact] - public void Select_Command_Raises_SetsFocus () + + [Theory] + [CombinatorialData] + public void Select_Command_Raises_SetsFocus (bool canFocus) { - var view = new ViewEventTester (); + var view = new ViewEventTester () + { + CanFocus = canFocus + }; + + Assert.Equal (canFocus, view.CanFocus); Assert.False (view.HasFocus); - Assert.False (view.InvokeCommand (Command.Select)); // false means it was not handled + Assert.Equal (canFocus, view.InvokeCommand (Command.Select)); Assert.Equal (1, view.OnSelectCount); Assert.Equal (1, view.SelectCount); - Assert.True (view.HasFocus); + Assert.Equal (canFocus, view.HasFocus); } [Fact] @@ -165,7 +172,7 @@ public class ViewCommandTests (ITestOutputHelper output) var view = new View (); var SelectInvoked = false; - view.Select += ViewOnSelect; + view.Selected += ViewOnSelect; bool? ret = view.InvokeCommand (Command.Select); Assert.True (ret); @@ -186,7 +193,7 @@ public class ViewCommandTests (ITestOutputHelper output) var view = new View (); var Selected = false; - view.Select += ViewOnSelect; + view.Selected += ViewOnSelect; view.InvokeCommand (Command.Select); Assert.True (Selected); @@ -228,20 +235,20 @@ public class ViewCommandTests (ITestOutputHelper output) { CanFocus = true; - Accept += (s, a) => + Accepted += (s, a) => { a.Handled = HandleAccept; AcceptCount++; }; - HotKeyCommand += (s, a) => + HotKeyHandled += (s, a) => { a.Handled = HandleHotKeyCommand; HotKeyCommandCount++; }; - Select += (s, a) => + Selected += (s, a) => { a.Handled = HandleSelect; SelectCount++; @@ -253,7 +260,7 @@ public class ViewCommandTests (ITestOutputHelper output) public bool HandleOnAccept { get; set; } /// - protected override bool OnAccept (HandledEventArgs args) + protected override bool OnAccepted (HandledEventArgs args) { OnAcceptCount++; @@ -267,7 +274,7 @@ public class ViewCommandTests (ITestOutputHelper output) public bool HandleOnHotKeyCommand { get; set; } /// - protected override bool OnHotKeyCommand (HandledEventArgs args) + protected override bool OnHotKeyHandled (HandledEventArgs args) { OnHotKeyCommandCount++; @@ -282,7 +289,7 @@ public class ViewCommandTests (ITestOutputHelper output) public bool HandleOnSelect { get; set; } /// - protected override bool OnSelect (HandledEventArgs args) + protected override bool OnSelected (HandledEventArgs args) { OnSelectCount++; diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs index f97d945eb..4c6ca5e83 100644 --- a/UnitTests/Views/ButtonTests.cs +++ b/UnitTests/Views/ButtonTests.cs @@ -249,7 +249,7 @@ public class ButtonTests (ITestOutputHelper output) { var clicked = false; var btn = new Button { Text = "_Test" }; - btn.Accept += (s, e) => clicked = true; + btn.Accepted += (s, e) => clicked = true; Assert.Equal (KeyCode.T, btn.HotKey); Assert.False (btn.NewKeyDownEvent (Key.T)); // Button processes, but does not handle @@ -280,7 +280,7 @@ public class ButtonTests (ITestOutputHelper output) button.CanFocus = focused; int acceptInvoked = 0; - button.Accept += (s, e) => acceptInvoked++; + button.Accepted += (s, e) => acceptInvoked++; superView.Add (button); button.SetFocus (); @@ -308,7 +308,7 @@ public class ButtonTests (ITestOutputHelper output) button.CanFocus = focused; int acceptInvoked = 0; - button.Accept += (s, e) => acceptInvoked++; + button.Accepted += (s, e) => acceptInvoked++; superView.Add (button); button.SetFocus (); @@ -339,7 +339,7 @@ public class ButtonTests (ITestOutputHelper output) button.CanFocus = focused; int acceptInvoked = 0; - button.Accept += (s, e) => acceptInvoked++; + button.Accepted += (s, e) => acceptInvoked++; superView.Add (button); button.SetFocus (); @@ -363,7 +363,7 @@ public class ButtonTests (ITestOutputHelper output) var pressed = 0; var btn = new Button { Text = "Press Me" }; - btn.Accept += (s, e) => pressed++; + btn.Accepted += (s, e) => pressed++; // The Button class supports the Default and Accept command Assert.Contains (Command.HotKey, btn.GetSupportedCommands ()); @@ -414,7 +414,7 @@ public class ButtonTests (ITestOutputHelper output) { var clicked = false; var btn = new Button { Text = "_Test" }; - btn.Accept += (s, e) => clicked = true; + btn.Accepted += (s, e) => clicked = true; var top = new Toplevel (); top.Add (btn); Application.Begin (top); @@ -483,7 +483,7 @@ public class ButtonTests (ITestOutputHelper output) var button = new Button (); var accepted = false; - button.Accept += ButtonOnAccept; + button.Accepted += ButtonOnAccept; button.InvokeCommand (Command.HotKey); Assert.True (accepted); @@ -500,7 +500,7 @@ public class ButtonTests (ITestOutputHelper output) var button = new Button (); var acceptInvoked = false; - button.Accept += ButtonAccept; + button.Accepted += ButtonAccept; bool? ret = button.InvokeCommand (Command.Accept); Assert.True (ret); @@ -610,7 +610,7 @@ public class ButtonTests (ITestOutputHelper output) var acceptCount = 0; - button.Accept += (s, e) => acceptCount++; + button.Accepted += (s, e) => acceptCount++; me.Flags = pressed; button.NewMouseEvent (me); @@ -645,7 +645,7 @@ public class ButtonTests (ITestOutputHelper output) var acceptCount = 0; - button.Accept += (s, e) => acceptCount++; + button.Accepted += (s, e) => acceptCount++; me.Flags = pressed; button.NewMouseEvent (me); diff --git a/UnitTests/Views/CheckBoxTests.cs b/UnitTests/Views/CheckBoxTests.cs index 4c3250460..da4ec69fa 100644 --- a/UnitTests/Views/CheckBoxTests.cs +++ b/UnitTests/Views/CheckBoxTests.cs @@ -181,10 +181,10 @@ public class CheckBoxTests (ITestOutputHelper output) ckb.CheckedStateChanging += (s, e) => checkedStateChangingCount++; int selectCount = 0; - ckb.Select += (s, e) => selectCount++; + ckb.Selected += (s, e) => selectCount++; int acceptCount = 0; - ckb.Accept += (s, e) => acceptCount++; + ckb.Accepted += (s, e) => acceptCount++; Assert.Equal (CheckState.UnChecked, ckb.CheckedState); Assert.Equal (0, checkedStateChangingCount); @@ -228,7 +228,7 @@ public class CheckBoxTests (ITestOutputHelper output) var ckb = new CheckBox (); var acceptInvoked = false; - ckb.Accept += ViewOnAccept; + ckb.Accepted += ViewOnAccept; bool? ret = ckb.InvokeCommand (Command.Accept); Assert.True (ret); @@ -256,10 +256,10 @@ public class CheckBoxTests (ITestOutputHelper output) checkBox.CheckedStateChanging += (s, e) => checkedStateChangingCount++; int selectCount = 0; - checkBox.Select += (s, e) => selectCount++; + checkBox.Selected += (s, e) => selectCount++; int acceptCount = 0; - checkBox.Accept += (s, e) => acceptCount++; + checkBox.Accepted += (s, e) => acceptCount++; checkBox.HasFocus = true; Assert.True (checkBox.HasFocus); @@ -300,10 +300,10 @@ public class CheckBoxTests (ITestOutputHelper output) checkBox.CheckedStateChanging += (s, e) => checkedStateChangingCount++; int selectCount = 0; - checkBox.Select += (s, e) => selectCount++; + checkBox.Selected += (s, e) => selectCount++; int acceptCount = 0; - checkBox.Accept += (s, e) => acceptCount++; + checkBox.Accepted += (s, e) => acceptCount++; checkBox.HasFocus = true; Assert.True (checkBox.HasFocus); @@ -544,7 +544,7 @@ public class CheckBoxTests (ITestOutputHelper output) var cb = new CheckBox (); var accepted = false; - cb.Accept += CheckBoxOnAccept; + cb.Accepted += CheckBoxOnAccept; cb.InvokeCommand (Command.HotKey); Assert.False (accepted); @@ -559,24 +559,24 @@ public class CheckBoxTests (ITestOutputHelper output) [InlineData (CheckState.Checked)] [InlineData (CheckState.UnChecked)] [InlineData (CheckState.None)] - public void Select_Handle_Event_Does_Not_Prevent_Change (CheckState initialState) + public void Selected_Handle_Event_Does_Not_Prevent_Change (CheckState initialState) { var ckb = new CheckBox { AllowCheckStateNone = true }; var checkedInvoked = false; ckb.CheckedState = initialState; - ckb.Select += OnSelect; + ckb.Selected += OnSelected; Assert.Equal (initialState, ckb.CheckedState); bool? ret = ckb.InvokeCommand (Command.Select); - Assert.False (ret); + Assert.True (ret); Assert.True (checkedInvoked); Assert.NotEqual (initialState, ckb.CheckedState); return; - void OnSelect (object sender, HandledEventArgs e) + void OnSelected (object sender, HandledEventArgs e) { checkedInvoked = true; e.Handled = true; diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs index f73a48db2..02f18f447 100644 --- a/UnitTests/Views/LabelTests.cs +++ b/UnitTests/Views/LabelTests.cs @@ -74,7 +74,7 @@ public class LabelTests (ITestOutputHelper output) var label = new Label (); var accepted = false; - label.Accept += LabelOnAccept; + label.Accepted += LabelOnAccept; label.InvokeCommand (Command.HotKey); Assert.False (accepted); diff --git a/UnitTests/Views/ListViewTests.cs b/UnitTests/Views/ListViewTests.cs index 22fceba09..18f95a21f 100644 --- a/UnitTests/Views/ListViewTests.cs +++ b/UnitTests/Views/ListViewTests.cs @@ -414,7 +414,7 @@ Item 6", var listView = new ListView (); var accepted = false; - listView.Accept += OnAccept; + listView.Accepted += OnAccept; listView.InvokeCommand (Command.HotKey); Assert.False (accepted); @@ -435,7 +435,7 @@ Item 6", var opened = false; var selectedValue = string.Empty; - listView.Accept += Accept; + listView.Accepted += Accept; listView.OpenSelectedItem += OpenSelectedItem; listView.InvokeCommand (Command.Accept); @@ -466,7 +466,7 @@ Item 6", var opened = false; var selectedValue = string.Empty; - listView.Accept += Accept; + listView.Accepted += Accept; listView.OpenSelectedItem += OpenSelectedItem; listView.InvokeCommand (Command.Accept); diff --git a/UnitTests/Views/MenuBarTests.cs b/UnitTests/Views/MenuBarTests.cs index dc9db17fc..9a7125391 100644 --- a/UnitTests/Views/MenuBarTests.cs +++ b/UnitTests/Views/MenuBarTests.cs @@ -238,7 +238,7 @@ public class MenuBarTests (ITestOutputHelper output) var btnClicked = false; var btn = new Button { Y = 4, Text = "Test" }; - btn.Accept += (s, e) => btnClicked = true; + btn.Accepted += (s, e) => btnClicked = true; var top = new Toplevel (); top.Add (menu, btn); Application.Begin (top); diff --git a/UnitTests/Views/RadioGroupTests.cs b/UnitTests/Views/RadioGroupTests.cs index 0fd96cdb6..79a0e5a9b 100644 --- a/UnitTests/Views/RadioGroupTests.cs +++ b/UnitTests/Views/RadioGroupTests.cs @@ -91,10 +91,10 @@ public class RadioGroupTests (ITestOutputHelper output) rg.SelectedItemChanged += (s, e) => selectedItemChangedCount++; var selectCount = 0; - rg.Select += (s, e) => selectCount++; + rg.Selected += (s, e) => selectCount++; var acceptCount = 0; - rg.Accept += (s, e) => acceptCount++; + rg.Accepted += (s, e) => acceptCount++; // By default the first item is selected Assert.Equal (0, rg.SelectedItem); @@ -186,7 +186,7 @@ public class RadioGroupTests (ITestOutputHelper output) Assert.Equal (0, rg.SelectedItem); Assert.Equal (1, rg.Cursor); - // Selected != Cursor - Select Cursor and raise Select event - DO NOT raise Accept + // Selected != Cursor - Raise HotKey event - Since we're focused, this should just advance Assert.True (Application.OnKeyDown (rg.HotKey)); Assert.Equal (1, rg.SelectedItem); Assert.Equal (1, rg.Cursor); @@ -220,10 +220,10 @@ public class RadioGroupTests (ITestOutputHelper output) rg.SelectedItemChanged += (s, e) => selectedItemChangedCount++; var selectCount = 0; - rg.Select += (s, e) => selectCount++; + rg.Selected += (s, e) => selectCount++; var acceptCount = 0; - rg.Accept += (s, e) => acceptCount++; + rg.Accepted += (s, e) => acceptCount++; // By default the first item is selected Assert.Equal (0, rg.SelectedItem); @@ -297,10 +297,10 @@ public class RadioGroupTests (ITestOutputHelper output) rg.SelectedItemChanged += (s, e) => selectedItemChangedCount++; var selectCount = 0; - rg.Select += (s, e) => selectCount++; + rg.Selected += (s, e) => selectCount++; var acceptCount = 0; - rg.Accept += (s, e) => acceptCount++; + rg.Accepted += (s, e) => acceptCount++; // By default the first item is selected Assert.Equal (0, rg.SelectedItem); @@ -492,7 +492,7 @@ public class RadioGroupTests (ITestOutputHelper output) var group = new RadioGroup { RadioLabels = new [] { "_Left", "_Right", "Cen_tered", "_Justified" } }; var accepted = false; - group.Accept += OnAccept; + group.Accepted += OnAccept; group.InvokeCommand (Command.HotKey); Assert.False (accepted); @@ -508,7 +508,7 @@ public class RadioGroupTests (ITestOutputHelper output) var group = new RadioGroup { RadioLabels = new [] { "_Left", "_Right", "Cen_tered", "_Justified" } }; var accepted = false; - group.Accept += OnAccept; + group.Accepted += OnAccept; group.InvokeCommand (Command.Accept); Assert.True (accepted); @@ -627,10 +627,10 @@ public class RadioGroupTests (ITestOutputHelper output) radioGroup.SelectedItemChanged += (s, e) => selectedItemChanged++; var selectCount = 0; - radioGroup.Select += (s, e) => selectCount++; + radioGroup.Selected += (s, e) => selectCount++; var acceptCount = 0; - radioGroup.Accept += (s, e) => acceptCount++; + radioGroup.Accepted += (s, e) => acceptCount++; Assert.Equal (Orientation.Vertical, radioGroup.Orientation); @@ -674,12 +674,12 @@ public class RadioGroupTests (ITestOutputHelper output) radioGroup.SelectedItemChanged += (s, e) => selectedItemChanged++; var selectCount = 0; - radioGroup.Select += (s, e) => selectCount++; + radioGroup.Selected += (s, e) => selectCount++; var acceptCount = 0; var handleAccept = false; - radioGroup.Accept += (s, e) => + radioGroup.Accepted += (s, e) => { acceptCount++; e.Handled = handleAccept; @@ -724,7 +724,7 @@ public class RadioGroupTests (ITestOutputHelper output) var superViewAcceptCount = 0; - superView.Accept += (s, a) => + superView.Accepted += (s, a) => { superViewAcceptCount++; a.Handled = true; diff --git a/UnitTests/Views/ScrollBarViewTests.cs b/UnitTests/Views/ScrollBarViewTests.cs index cd02cef99..e2a15ebba 100644 --- a/UnitTests/Views/ScrollBarViewTests.cs +++ b/UnitTests/Views/ScrollBarViewTests.cs @@ -1154,7 +1154,7 @@ This is a test var text = "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test"; var label = new Label { Width = 14, Height = 5, Text = text }; var btn = new Button { X = 14, Text = "Click Me!" }; - btn.Accept += (s, e) => clicked = true; + btn.Accepted += (s, e) => clicked = true; var top = new Toplevel (); top.Add (label, btn); diff --git a/UnitTests/Views/ShortcutTests.cs b/UnitTests/Views/ShortcutTests.cs index 79474d9bb..5ae5268ef 100644 --- a/UnitTests/Views/ShortcutTests.cs +++ b/UnitTests/Views/ShortcutTests.cs @@ -425,7 +425,7 @@ public class ShortcutTests Application.Begin (current); var accepted = 0; - shortcut.Accept += (s, e) => accepted++; + shortcut.Accepted += (s, e) => accepted++; Application.OnMouseEvent ( new () @@ -445,15 +445,15 @@ public class ShortcutTests // 0123456789 // " C 0 A " [InlineData (-1, 0, 0, 0, 0)] - [InlineData (0, 1, 0, 0, 1)] // mouseX = 0 is on the CommandView.Margin, so Shortcut will get MouseClick - [InlineData (1, 0, 0, 0, 1)] // mouseX = 1 is on the CommandView, so CommandView will get MouseClick - [InlineData (2, 1, 0, 0, 1)] // mouseX = 2 is on the CommandView.Margin, so Shortcut will get MouseClick - [InlineData (3, 0, 0, 0, 1)] - [InlineData (4, 0, 0, 0, 1)] - [InlineData (5, 0, 0, 1, 1)] - [InlineData (6, 0, 0, 1, 1)] - [InlineData (7, 0, 0, 1, 1)] - [InlineData (8, 0, 0, 1, 1)] + [InlineData (0, 0, 1, 1, 1)] // mouseX = 0 is on the CommandView.Margin, so Shortcut will get MouseClick + [InlineData (1, 0, 1, 1, 1)] // mouseX = 1 is on the CommandView, so CommandView will get MouseClick + [InlineData (2, 1, 1, 1, 1)] // mouseX = 2 is on the CommandView.Margin, so Shortcut will get MouseClick + [InlineData (3, 0, 1, 1, 1)] + [InlineData (4, 0, 1, 1, 1)] + [InlineData (5, 0, 1, 1, 1)] + [InlineData (6, 0, 1, 1, 1)] + [InlineData (7, 0, 1, 1, 1)] + [InlineData (8, 0, 1, 1, 1)] [InlineData (9, 0, 0, 0, 0)] //[InlineData (1, 1, 1)] @@ -465,7 +465,8 @@ public class ShortcutTests //[InlineData (7, 1, 0)] //[InlineData (8, 1, 0)] //[InlineData (9, 0, 0)] - public void MouseClick_Default_CommandView_Raises_Accept_Select_Correctly (int mouseX, int expectedCommandViewAccept, int expectedCommandViewSelect, int expectedShortcutAccept, int expectedShortcutSelect) + public void MouseClick_Default_CommandView_Raises_Accept_Select_Correctly (int mouseX, int expectedCommandViewAccept, int expectedCommandViewSelect, + int expectedShortcutAccept, int expectedShortcutSelect) { Application.Top = new Toplevel (); @@ -477,23 +478,23 @@ public class ShortcutTests }; var commandViewAcceptCount = 0; - shortcut.CommandView.Accept += (s, e) => + shortcut.CommandView.Accepted += (s, e) => { commandViewAcceptCount++; }; var commandViewSelectCount = 0; - shortcut.CommandView.Select += (s, e) => + shortcut.CommandView.Selected += (s, e) => { commandViewSelectCount++; }; var shortcutAcceptCount = 0; - shortcut.Accept += (s, e) => + shortcut.Accepted += (s, e) => { shortcutAcceptCount++; }; var shortcutSelectCount = 0; - shortcut.Select += (s, e) => + shortcut.Selected += (s, e) => { shortcutSelectCount++; }; @@ -511,8 +512,8 @@ public class ShortcutTests }); Assert.Equal (expectedShortcutAccept, shortcutAcceptCount); - Assert.Equal (expectedCommandViewAccept, commandViewAcceptCount); Assert.Equal (expectedShortcutSelect, shortcutSelectCount); + Assert.Equal (expectedCommandViewAccept, commandViewAcceptCount); Assert.Equal (expectedCommandViewSelect, commandViewSelectCount); Application.Top.Dispose (); @@ -534,7 +535,8 @@ public class ShortcutTests [InlineData (7, 1, 0)] [InlineData (8, 1, 0)] [InlineData (9, 0, 0)] - public void MouseClick_Button_CommandView_Fires_Shortcut_Accept (int mouseX, int expectedAccept, int expectedButtonAccept) + public void MouseClick_Button_CommandView_Raises_Shortcut_Accept + (int mouseX, int expectedAccept, int expectedButtonAccept) { Application.Top = new Toplevel (); @@ -552,7 +554,7 @@ public class ShortcutTests CanFocus = false }; var buttonAccepted = 0; - shortcut.CommandView.Accept += (s, e) => + shortcut.CommandView.Accepted += (s, e) => { buttonAccepted++; // Must indicate handled @@ -561,7 +563,7 @@ public class ShortcutTests Application.Top.Add (shortcut); var accepted = 0; - shortcut.Accept += (s, e) => accepted++; + shortcut.Accepted += (s, e) => accepted++; //Assert.True (shortcut.HasFocus); @@ -610,7 +612,7 @@ public class ShortcutTests Assert.Equal (canFocus, shortcut.HasFocus); var accepted = 0; - shortcut.Accept += (s, e) => accepted++; + shortcut.Accepted += (s, e) => accepted++; Application.OnKeyDown (key); @@ -641,7 +643,7 @@ public class ShortcutTests Application.Top.SetFocus (); var accepted = 0; - shortcut.Accept += (s, e) => accepted++; + shortcut.Accepted += (s, e) => accepted++; Application.OnKeyDown (key); @@ -704,7 +706,6 @@ public class ShortcutTests [InlineData (false, KeyCode.Enter, 0)] [InlineData (false, KeyCode.Space, 0)] [InlineData (false, KeyCode.F1, 0)] - [AutoInitShutdown] public void KeyDown_App_Scope_Invokes_Action (bool canFocus, KeyCode key, int expectedAction) { Application.Top = new Toplevel (); diff --git a/UnitTests/Views/TextFieldTests.cs b/UnitTests/Views/TextFieldTests.cs index 6af276a6b..9be4e42be 100644 --- a/UnitTests/Views/TextFieldTests.cs +++ b/UnitTests/Views/TextFieldTests.cs @@ -766,7 +766,7 @@ public class TextFieldTests (ITestOutputHelper output) { var view = new TextField (); var accepted = false; - view.Accept += OnAccept; + view.Accepted += OnAccept; view.InvokeCommand (Command.HotKey); Assert.False (accepted); @@ -782,7 +782,7 @@ public class TextFieldTests (ITestOutputHelper output) var view = new TextField (); var accepted = false; - view.Accept += Accept; + view.Accepted += Accept; view.InvokeCommand (Command.Accept); Assert.True (accepted); @@ -814,10 +814,10 @@ public class TextFieldTests (ITestOutputHelper output) superView.Add (tf, button); var buttonAccept = 0; - button.Accept += ButtonAccept; + button.Accepted += ButtonAccept; var textFieldAccept = 0; - tf.Accept += TextFieldAccept; + tf.Accepted += TextFieldAccept; tf.SetFocus (); Assert.True (tf.HasFocus); @@ -866,7 +866,7 @@ public class TextFieldTests (ITestOutputHelper output) superView.Add (tf, button); var buttonAccept = 0; - button.Accept += ButtonAccept; + button.Accepted += ButtonAccept; tf.SetFocus (); Assert.True (tf.HasFocus); @@ -898,13 +898,13 @@ public class TextFieldTests (ITestOutputHelper output) var tfAcceptedInvoked = false; var handle = false; - view.Accept += TextViewAccept; + view.Accepted += TextViewAccept; Assert.False (view.InvokeCommand (Command.Accept)); Assert.True (tfAcceptedInvoked); tfAcceptedInvoked = false; handle = true; - view.Accept += TextViewAccept; + view.Accepted += TextViewAccept; Assert.True (view.InvokeCommand (Command.Accept)); Assert.True (tfAcceptedInvoked); diff --git a/UnitTests/Views/TextViewTests.cs b/UnitTests/Views/TextViewTests.cs index a47242b69..d640c59e0 100644 --- a/UnitTests/Views/TextViewTests.cs +++ b/UnitTests/Views/TextViewTests.cs @@ -8464,7 +8464,7 @@ line. { var view = new TextView (); var accepted = false; - view.Accept += OnAccept; + view.Accepted += OnAccept; view.InvokeCommand (Command.HotKey); Assert.False (accepted); @@ -8485,7 +8485,7 @@ line. }; int acceptEvents = 0; - view.Accept += Accept; + view.Accepted += Accept; view.InvokeCommand (Command.Accept); Assert.Equal (expectedAcceptEvents, acceptEvents); @@ -8505,7 +8505,7 @@ line. }; int accepted = 0; - view.Accept += Accept; + view.Accepted += Accept; view.NewKeyDownEvent (Key.Enter); Assert.Equal (expectedAccepts, accepted); @@ -8525,7 +8525,7 @@ line. }; int accepted = 0; - view.Accept += Accept; + view.Accepted += Accept; view.NewKeyDownEvent (Key.Enter); Assert.Equal (expectedAccepts, accepted); @@ -8554,10 +8554,10 @@ line. superView.Add (tv, button); var buttonAccept = 0; - button.Accept += ButtonAccept; + button.Accepted += ButtonAccept; var textViewAccept = 0; - tv.Accept += TextViewAccept; + tv.Accepted += TextViewAccept; tv.SetFocus (); Assert.True (tv.HasFocus); @@ -8603,7 +8603,7 @@ line. superView.Add (tv, button); var buttonAccept = 0; - button.Accept += ButtonAccept; + button.Accepted += ButtonAccept; tv.SetFocus (); Assert.True (tv.HasFocus); diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index 69d71712a..305c1a00b 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -947,7 +947,7 @@ public partial class ToplevelTests (ITestOutputHelper output) var testWindow = new Window { X = 2, Y = 1, Width = 15, Height = 10 }; testWindow.Add (btnPopup); - btnPopup.Accept += (s, e) => + btnPopup.Accepted += (s, e) => { Rectangle viewToScreen = btnPopup.ViewportToScreen (top.Frame); diff --git a/UnitTests/Views/TreeViewTests.cs b/UnitTests/Views/TreeViewTests.cs index 915630267..e75dcfca5 100644 --- a/UnitTests/Views/TreeViewTests.cs +++ b/UnitTests/Views/TreeViewTests.cs @@ -1344,7 +1344,7 @@ oot two var treeView = new TreeView (); var accepted = false; - treeView.Accept += OnAccept; + treeView.Accepted += OnAccept; treeView.InvokeCommand (Command.HotKey); Assert.False (accepted); @@ -1365,7 +1365,7 @@ oot two var activated = false; object selectedObject = null; - treeView.Accept += Accept; + treeView.Accepted += Accept; treeView.ObjectActivated += ObjectActivated; treeView.InvokeCommand (Command.Accept); @@ -1393,7 +1393,7 @@ oot two var activated = false; object selectedObject = null; - treeView.Accept += Accept; + treeView.Accepted += Accept; treeView.ObjectActivated += ObjectActivated; treeView.InvokeCommand (Command.Accept);