From e7a4df492d36ce4ce4b15b24b6f46634a72571b3 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Dec 2025 12:42:34 -0700 Subject: [PATCH] Fixes #4050. Rename Command.Select and Selecting to Activate/Activating (#4470) * Initial plan * Rename Command.Select to Command.Activate and Selecting to Activating Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add Activating event propagation to SuperView Co-authored-by: tig <585482+tig@users.noreply.github.com> * Update all comments and docs referencing Select to Activate Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix event log messages in examples to use Activating/Activate Co-authored-by: tig <585482+tig@users.noreply.github.com> * Revert automatic Activating event propagation that broke tests Co-authored-by: tig <585482+tig@users.noreply.github.com> * Update docfx documentation to use Activate/Activating terminology Co-authored-by: tig <585482+tig@users.noreply.github.com> * renames * Revert "Add Activating event propagation to SuperView" This reverts commit 6d82bee9ad7b4b93c15b2e2af968e38046b8f56a. * added command diagrams * mermaid * updated level 3 * again * Select->Activate in MouseTests.cs * Update Terminal.Gui/Views/Selectors/FlagSelector.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor: Rename Selecting to Activating in View APIs Renamed the `Selecting` event and `OnSelecting` method to `Activating` and `OnActivating` to better reflect their purpose. Updated all related comments, test method names, variables, and assertions in `View` and `ViewCommandTests` to align with the new terminology. Improved code clarity by using `_` for unused parameters in lambda expressions. Renamed properties like `HandleSelecting` to `HandleActivating` and adjusted naming conventions for consistency (e.g., `OnactivatingCount` to `OnActivatingCount`). These changes enhance readability, maintainability, and terminology consistency across the codebase. * Update Terminal.Gui/Views/Selectors/OptionSelector.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Typos --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Scenarios/CharacterMap/CharacterMap.cs | 2 +- Examples/UICatalog/Scenarios/ContextMenus.cs | 6 +- .../Scenarios/EditorsAndHelpers/EventLog.cs | 2 +- .../Scenarios/ListViewWithSelection.cs | 2 +- Examples/UICatalog/Scenarios/Shortcuts.cs | 10 +- Examples/UICatalog/Scenarios/TableEditor.cs | 2 +- .../UICatalog/Scenarios/TreeViewFileSystem.cs | 2 +- .../UICatalog/Scenarios/ViewExperiments.cs | 2 +- Examples/UICatalog/UICatalogRunnable.cs | 4 +- Terminal.Gui/Input/Command.cs | 7 +- Terminal.Gui/ViewBase/View.Command.cs | 36 +-- Terminal.Gui/ViewBase/View.Keyboard.cs | 2 +- Terminal.Gui/ViewBase/View.Mouse.cs | 14 +- Terminal.Gui/Views/Button.cs | 4 +- Terminal.Gui/Views/CharMap/CharMap.cs | 6 +- Terminal.Gui/Views/CheckBox.cs | 6 +- Terminal.Gui/Views/Color/ColorPicker.16.cs | 10 +- Terminal.Gui/Views/FileDialogs/FileDialog.cs | 6 +- Terminal.Gui/Views/HexView.cs | 10 +- Terminal.Gui/Views/Label.cs | 4 +- Terminal.Gui/Views/ListView.cs | 20 +- Terminal.Gui/Views/NumericUpDown.cs | 4 +- Terminal.Gui/Views/ScrollBar/ScrollBar.cs | 6 +- Terminal.Gui/Views/ScrollBar/ScrollSlider.cs | 2 +- Terminal.Gui/Views/Selectors/FlagSelector.cs | 18 +- .../Views/Selectors/OptionSelector.cs | 20 +- Terminal.Gui/Views/Selectors/SelectorBase.cs | 8 +- Terminal.Gui/Views/Shortcut.cs | 26 +-- Terminal.Gui/Views/Slider/Slider.cs | 4 +- Terminal.Gui/Views/TabView/TabRow.cs | 4 +- Terminal.Gui/Views/TabView/TabView.cs | 16 +- .../TableView/CheckBoxTableSourceWrapper.cs | 6 +- .../Views/TableView/TableSelection.cs | 2 +- Terminal.Gui/Views/TableView/TableView.cs | 8 +- .../Views/TableView/TreeTableSource.cs | 6 +- Terminal.Gui/Views/TreeView/TreeView.cs | 4 +- Tests/UnitTests/View/Mouse/MouseTests.cs | 8 +- Tests/UnitTests/Views/ButtonTests.cs | 20 +- Tests/UnitTests/Views/CheckBoxTests.cs | 4 +- Tests/UnitTests/Views/ShortcutTests.cs | 32 +-- Tests/UnitTests/Views/TableViewTests.cs | 8 +- .../ViewBase/Keyboard/KeyBindingsTests.cs | 2 +- .../ViewBase/Mouse/MouseEventRoutingTests.cs | 14 +- .../ViewBase/Mouse/MouseTests.cs | 10 +- .../ViewBase/ViewCommandTests.cs | 78 +++---- .../Views/AllViewsTests.cs | 14 +- .../Views/CheckBoxTests.cs | 6 +- .../Views/ShortcutTests.cs | 2 +- .../Views/TextFieldTests.cs | 8 +- docfx/docs/View.md | 10 +- docfx/docs/command-diagrams.md | 101 ++++++++ docfx/docs/command.md | 220 ++++++++++-------- docfx/docs/events.md | 6 +- docfx/docs/index.md | 2 +- docfx/docs/migratingfromv1.md | 24 +- docfx/docs/mouse.md | 36 +-- docfx/docs/navigation.md | 6 +- 57 files changed, 512 insertions(+), 390 deletions(-) create mode 100644 docfx/docs/command-diagrams.md diff --git a/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs b/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs index daddc307e..1c57c4bec 100644 --- a/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs +++ b/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs @@ -134,7 +134,7 @@ public class CharacterMap : Scenario _categoryList.Table = CreateCategoryTable (0, isDescending); // if user clicks the mouse in TableView - _categoryList.Selecting += (_, e) => + _categoryList.Activating += (_, e) => { // Only handle mouse clicks if (e.Context is not CommandContext { Binding.MouseEventArgs: { } mouseArgs }) diff --git a/Examples/UICatalog/Scenarios/ContextMenus.cs b/Examples/UICatalog/Scenarios/ContextMenus.cs index 1c6170c5b..ddb52f484 100644 --- a/Examples/UICatalog/Scenarios/ContextMenus.cs +++ b/Examples/UICatalog/Scenarios/ContextMenus.cs @@ -35,7 +35,7 @@ public class ContextMenus : Scenario Application.Run (_appWindow); _appWindow.Dispose (); _appWindow.KeyDown -= OnAppWindowOnKeyDown; - _appWindow.Selecting -= OnAppWindowOnSelecting; + _appWindow.Activating -= OnAppWindowOnActivating; _winContextMenu?.Dispose (); // Shutdown - Calling Application.Shutdown is required. @@ -81,7 +81,7 @@ public class ContextMenus : Scenario _appWindow.Add (_tfBottomRight); _appWindow.KeyDown += OnAppWindowOnKeyDown; - _appWindow.Selecting += OnAppWindowOnSelecting; + _appWindow.Activating += OnAppWindowOnActivating; CultureInfo originalCulture = Thread.CurrentThread.CurrentUICulture; _appWindow.IsRunningChanged += (_, e) => { @@ -91,7 +91,7 @@ public class ContextMenus : Scenario } }; } - void OnAppWindowOnSelecting (object? s, CommandEventArgs e) + void OnAppWindowOnActivating (object? s, CommandEventArgs e) { if (e.Context is CommandContext { Binding.MouseEventArgs: { } mouseArgs }) { diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs index af4cb3e88..4bdd61066 100644 --- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs +++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs @@ -81,7 +81,7 @@ public class EventLog : ListView _viewToLog.MouseWheel += (_, args) => { Log ($"MouseWheel: {args}"); }; _viewToLog.HandlingHotKey += (_, args) => { Log ($"HandlingHotKey: {args.Context}"); }; - _viewToLog.Selecting += (_, args) => { Log ($"Selecting: {args.Context}"); }; + _viewToLog.Activating += (_, args) => { Log ($"Activating: {args.Context}"); }; _viewToLog.Accepting += (_, args) => { Log ($"Accepting: {args.Context}"); }; } } diff --git a/Examples/UICatalog/Scenarios/ListViewWithSelection.cs b/Examples/UICatalog/Scenarios/ListViewWithSelection.cs index dd6ac2bf4..62c8844fa 100644 --- a/Examples/UICatalog/Scenarios/ListViewWithSelection.cs +++ b/Examples/UICatalog/Scenarios/ListViewWithSelection.cs @@ -105,7 +105,7 @@ public class ListViewWithSelection : Scenario _listView.OpenSelectedItem += (s, a) => LogEvent (s as View, a, "OpenSelectedItem"); _listView.CollectionChanged += (s, a) => LogEvent (s as View, a, "CollectionChanged"); _listView.Accepting += (s, a) => LogEvent (s as View, a, "Accept"); - _listView.Selecting += (s, a) => LogEvent (s as View, a, "Select"); + _listView.Activating += (s, a) => LogEvent (s as View, a, "Activate"); _listView.VerticalScrollBar.AutoShow = true; _listView.HorizontalScrollBar.AutoShow = true; diff --git a/Examples/UICatalog/Scenarios/Shortcuts.cs b/Examples/UICatalog/Scenarios/Shortcuts.cs index a2e241c6c..e76dcfc05 100644 --- a/Examples/UICatalog/Scenarios/Shortcuts.cs +++ b/Examples/UICatalog/Scenarios/Shortcuts.cs @@ -425,7 +425,7 @@ public class Shortcuts : Scenario BoxWidth = 1 }; - bgColorShortcut.Selecting += (o, args) => + bgColorShortcut.Activating += (o, args) => { //args.Cancel = true; }; @@ -480,18 +480,18 @@ public class Shortcuts : Scenario foreach (Shortcut shortcut in Application.TopRunnableView.SubViews.OfType ()) { - shortcut.Selecting += (o, args) => + shortcut.Activating += (o, args) => { if (args.Handled) { return; } - eventSource.Add ($"{shortcut!.Id}.Selecting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}"); + eventSource.Add ($"{shortcut!.Id}.Activating: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}"); eventLog.MoveDown (); }; - shortcut.CommandView.Selecting += (o, args) => + shortcut.CommandView.Activating += (o, args) => { if (args.Handled) { @@ -499,7 +499,7 @@ public class Shortcuts : Scenario } eventSource.Add ( - $"{shortcut!.Id}.CommandView.Selecting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}"); + $"{shortcut!.Id}.CommandView.Activating: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}"); eventLog.MoveDown (); //args.Handled = true; }; diff --git a/Examples/UICatalog/Scenarios/TableEditor.cs b/Examples/UICatalog/Scenarios/TableEditor.cs index 0ca8092d0..04d2bba24 100644 --- a/Examples/UICatalog/Scenarios/TableEditor.cs +++ b/Examples/UICatalog/Scenarios/TableEditor.cs @@ -610,7 +610,7 @@ public class TableEditor : Scenario }; // if user clicks the mouse in TableView - _tableView!.Selecting += (s, e) => + _tableView!.Activating += (s, e) => { if (_currentTable == null) { diff --git a/Examples/UICatalog/Scenarios/TreeViewFileSystem.cs b/Examples/UICatalog/Scenarios/TreeViewFileSystem.cs index 3753ac35d..75f0d822d 100644 --- a/Examples/UICatalog/Scenarios/TreeViewFileSystem.cs +++ b/Examples/UICatalog/Scenarios/TreeViewFileSystem.cs @@ -60,7 +60,7 @@ public class TreeViewFileSystem : Scenario }; win.Add (_detailsFrame); - _treeViewFiles.Selecting += TreeViewFiles_Selecting; + _treeViewFiles.Activating += TreeViewFiles_Selecting; _treeViewFiles.KeyDown += TreeViewFiles_KeyPress; _treeViewFiles.SelectionChanged += TreeViewFiles_SelectionChanged; diff --git a/Examples/UICatalog/Scenarios/ViewExperiments.cs b/Examples/UICatalog/Scenarios/ViewExperiments.cs index aeeaa14c9..786541334 100644 --- a/Examples/UICatalog/Scenarios/ViewExperiments.cs +++ b/Examples/UICatalog/Scenarios/ViewExperiments.cs @@ -86,7 +86,7 @@ public class ViewExperiments : Scenario //App?.Popover!.Visible = true; } - testFrame.Selecting += (sender, e) => + testFrame.Activating += (sender, e) => { if (e.Context is CommandContext { Binding.MouseEventArgs: { } mouseArgs }) { diff --git a/Examples/UICatalog/UICatalogRunnable.cs b/Examples/UICatalog/UICatalogRunnable.cs index 748c2a5dc..3df05b8ae 100644 --- a/Examples/UICatalog/UICatalogRunnable.cs +++ b/Examples/UICatalog/UICatalogRunnable.cs @@ -298,7 +298,7 @@ public class UICatalogRunnable : Runnable _diagnosticFlagsSelector.UsedHotKeys.Add (Key.D); _diagnosticFlagsSelector.AssignHotKeys = true; _diagnosticFlagsSelector.Value = Diagnostics; - _diagnosticFlagsSelector.Selecting += (sender, args) => + _diagnosticFlagsSelector.Activating += (sender, args) => { _diagnosticFlags = (ViewDiagnosticFlags)((int)args.Context!.Source!.Data!);// (ViewDiagnosticFlags)_diagnosticFlagsSelector.Value; Diagnostics = _diagnosticFlags; @@ -330,7 +330,7 @@ public class UICatalogRunnable : Runnable }; //_disableMouseCb.CheckedStateChanged += (_, args) => { Application.IsMouseDisabled = args.Value == CheckState.Checked; }; - _disableMouseCb.Selecting += (sender, args) => + _disableMouseCb.Activating += (sender, args) => { Application.IsMouseDisabled = !Application.IsMouseDisabled; _disableMouseCb.CheckedState = Application.IsMouseDisabled ? CheckState.Checked : CheckState.None; diff --git a/Terminal.Gui/Input/Command.cs b/Terminal.Gui/Input/Command.cs index 4d1b6d008..88e7f4a43 100644 --- a/Terminal.Gui/Input/Command.cs +++ b/Terminal.Gui/Input/Command.cs @@ -48,12 +48,13 @@ public enum Command HotKey, /// - /// Selects the View or an item in the View (e.g. a list item or menu item) without necessarily accepting it. + /// Activates the View or an item in the View, changing its state or preparing it for interaction + /// (e.g. toggling a checkbox, selecting a list item, focusing a button, navigating a menu item) without necessarily accepting it. /// - /// The default implementation in calls . + /// The default implementation in calls . /// /// - Select, + Activate, #endregion diff --git a/Terminal.Gui/ViewBase/View.Command.cs b/Terminal.Gui/ViewBase/View.Command.cs index 0c7a87948..0ab3578a4 100644 --- a/Terminal.Gui/ViewBase/View.Command.cs +++ b/Terminal.Gui/ViewBase/View.Command.cs @@ -35,19 +35,19 @@ public partial class View // Command APIs return true; }); - // Space or single-click - Raise Selecting + // Space or single-click - Raise Activating AddCommand ( - Command.Select, + Command.Activate, ctx => { - if (RaiseSelecting (ctx) is true) + if (RaiseActivating (ctx) is true) { return true; } if (CanFocus) { - // For Select, if the view is focusable and SetFocus succeeds, by defition, + // For Activate, if the view is focusable and SetFocus succeeds, by defition, // the event is handled. So return what SetFocus returns. return SetFocus (); } @@ -106,7 +106,7 @@ public partial class View // Command APIs /// /// /// The event should be raised after the state of the View has changed (after - /// is raised). + /// is raised). /// /// /// If the Accepting event is not handled, will be invoked on the SuperView, enabling @@ -251,12 +251,12 @@ public partial class View // Command APIs public event EventHandler? Accepted; /// - /// Called when the user has performed an action (e.g. ) causing the View to change state. - /// Calls which can be cancelled; if not cancelled raises . - /// event. The default handler calls this method. + /// Called when the user has performed an action (e.g. ) causing the View to change state or preparing it for interaction. + /// Calls which can be cancelled; if not cancelled raises . + /// event. The default handler calls this method. /// /// - /// The event should be raised after the state of the View has been changed and before see + /// The event should be raised after the state of the View has been changed and before see /// . /// /// @@ -265,40 +265,40 @@ public partial class View // Command APIs /// continue. /// if the event was raised and handled (or cancelled); input processing should stop. /// - protected bool? RaiseSelecting (ICommandContext? ctx) + protected virtual bool? RaiseActivating (ICommandContext? ctx) { //Logging.Debug ($"{Title} ({ctx?.Source?.Title})"); CommandEventArgs args = new () { Context = ctx }; // Best practice is to invoke the virtual method first. // This allows derived classes to handle the event and potentially cancel it. - if (OnSelecting (args) || args.Handled) + if (OnActivating (args) || args.Handled) { return true; } // If the event is not canceled by the virtual method, raise the event to notify any external subscribers. - Selecting?.Invoke (this, args); + Activating?.Invoke (this, args); - return Selecting is null ? null : args.Handled; + return Activating is null ? null : args.Handled; } /// - /// Called when the user has performed an action (e.g. ) causing the View to change state. + /// Called when the user has performed an action (e.g. ) causing the View to change state or preparing it for interaction. /// Set CommandEventArgs.Handled to and return to indicate the event was /// handled and processing should stop. /// /// The event arguments. /// to stop processing. - protected virtual bool OnSelecting (CommandEventArgs args) { return false; } + protected virtual bool OnActivating (CommandEventArgs args) { return false; } /// - /// Cancelable event raised when the user has performed an action (e.g. ) causing the View - /// to change state. + /// Cancelable event raised when the user has performed an action (e.g. ) causing the View + /// to change state or preparing it for interaction. /// Set CommandEventArgs.Handled to to indicate the event was handled and processing should /// stop. /// - public event EventHandler? Selecting; + public event EventHandler? Activating; /// /// Called when the View is handling the user pressing the View's s. Calls diff --git a/Terminal.Gui/ViewBase/View.Keyboard.cs b/Terminal.Gui/ViewBase/View.Keyboard.cs index 8f9a5127a..867b324b6 100644 --- a/Terminal.Gui/ViewBase/View.Keyboard.cs +++ b/Terminal.Gui/ViewBase/View.Keyboard.cs @@ -9,7 +9,7 @@ public partial class View // Keyboard APIs private void SetupKeyboard () { KeyBindings = new (this); - KeyBindings.Add (Key.Space, Command.Select); + KeyBindings.Add (Key.Space, Command.Activate); KeyBindings.Add (Key.Enter, Command.Accept); HotKeyBindings = new (this); diff --git a/Terminal.Gui/ViewBase/View.Mouse.cs b/Terminal.Gui/ViewBase/View.Mouse.cs index 60a41d1f3..a1df6dd59 100644 --- a/Terminal.Gui/ViewBase/View.Mouse.cs +++ b/Terminal.Gui/ViewBase/View.Mouse.cs @@ -20,11 +20,11 @@ public partial class View // Mouse APIs MouseBindings = new (); // TODO: Should the default really work with any button or just button1? - MouseBindings.Add (MouseFlags.Button1Clicked, Command.Select); - MouseBindings.Add (MouseFlags.Button2Clicked, Command.Select); - MouseBindings.Add (MouseFlags.Button3Clicked, Command.Select); - MouseBindings.Add (MouseFlags.Button4Clicked, Command.Select); - MouseBindings.Add (MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl, Command.Select); + MouseBindings.Add (MouseFlags.Button1Clicked, Command.Activate); + MouseBindings.Add (MouseFlags.Button2Clicked, Command.Activate); + MouseBindings.Add (MouseFlags.Button3Clicked, Command.Activate); + MouseBindings.Add (MouseFlags.Button4Clicked, Command.Activate); + MouseBindings.Add (MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl, Command.Activate); } /// @@ -278,8 +278,8 @@ public partial class View // Mouse APIs /// outside the view's . /// /// - /// Most views should handle mouse clicks by subscribing to the event or - /// overriding rather than overriding this method. Override this method + /// Most views should handle mouse clicks by subscribing to the event or + /// overriding rather than overriding this method. Override this method /// only for custom low-level mouse handling (e.g., drag-and-drop). /// /// diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index 7b0bc4779..c05e5d3ad 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -75,7 +75,7 @@ public class Button : View, IDesignable KeyBindings.Remove (Key.Enter); KeyBindings.Add (Key.Enter, Command.HotKey); - // Replace default Select binding with HotKey for mouse clicks + // Replace default Activate binding with HotKey for mouse clicks MouseBindings.Clear (); MouseBindings.Add (MouseFlags.Button1Clicked, Command.HotKey); MouseBindings.Add (MouseFlags.Button2Clicked, Command.HotKey); @@ -98,7 +98,7 @@ public class Button : View, IDesignable { bool cachedIsDefault = IsDefault; // Supports "Swap Default" in Buttons scenario where IsDefault changes - if (RaiseSelecting (commandContext) is true) + if (RaiseActivating (commandContext) is true) { return true; } diff --git a/Terminal.Gui/Views/CharMap/CharMap.cs b/Terminal.Gui/Views/CharMap/CharMap.cs index c9adeedb3..3fcf395da 100644 --- a/Terminal.Gui/Views/CharMap/CharMap.cs +++ b/Terminal.Gui/Views/CharMap/CharMap.cs @@ -45,7 +45,7 @@ public class CharMap : View, IDesignable AddCommand (Command.ScrollLeft, () => ScrollHorizontal (-1)); AddCommand (Command.Accept, HandleAcceptCommand); - AddCommand (Command.Select, HandleSelectCommand); + AddCommand (Command.Activate, HandleSelectCommand); AddCommand (Command.Context, HandleContextCommand); KeyBindings.Add (Key.CursorUp, Command.Up); @@ -286,7 +286,7 @@ public class CharMap : View, IDesignable private bool? Move (ICommandContext? commandContext, int cpOffset) { - if (RaiseSelecting (commandContext) is true) + if (RaiseActivating (commandContext) is true) { return true; } @@ -865,7 +865,7 @@ public class CharMap : View, IDesignable } } - if (RaiseSelecting (commandContext) is true) + if (RaiseActivating (commandContext) is true) { return true; } diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs index 0dfb47e51..48950faec 100644 --- a/Terminal.Gui/Views/CheckBox.cs +++ b/Terminal.Gui/Views/CheckBox.cs @@ -33,7 +33,7 @@ public class CheckBox : View // Activate (Space key and single-click) - Raise Activate event and Advance // - DO NOT raise Accept // - DO NOT SetFocus - AddCommand (Command.Select, ActivateAndAdvance); + AddCommand (Command.Activate, ActivateAndAdvance); // Accept (Enter key and double-click) - Raise Accept event // - DO NOT advance state @@ -49,7 +49,7 @@ public class CheckBox : View protected override bool OnHandlingHotKey (CommandEventArgs args) { // Invoke Activate on ourselves - if (InvokeCommand (Command.Select, args.Context) is true) + if (InvokeCommand (Command.Activate, args.Context) is true) { // Default behavior for View is to set Focus on hotkey. We need to return // true here to indicate Activate was handled. That will prevent the default @@ -62,7 +62,7 @@ public class CheckBox : View private bool? ActivateAndAdvance (ICommandContext? commandContext) { - if (RaiseSelecting (commandContext) is true) + if (RaiseActivating (commandContext) is true) { return true; } diff --git a/Terminal.Gui/Views/Color/ColorPicker.16.cs b/Terminal.Gui/Views/Color/ColorPicker.16.cs index 23620cfe0..43b27dca8 100644 --- a/Terminal.Gui/Views/Color/ColorPicker.16.cs +++ b/Terminal.Gui/Views/Color/ColorPicker.16.cs @@ -70,7 +70,7 @@ public class ColorPicker16 : View /// private bool MoveDown (ICommandContext? commandContext) { - if (RaiseSelecting (commandContext) == true) + if (RaiseActivating (commandContext) == true) { return true; } @@ -86,7 +86,7 @@ public class ColorPicker16 : View /// private bool MoveLeft (ICommandContext? commandContext) { - if (RaiseSelecting (commandContext) == true) + if (RaiseActivating (commandContext) == true) { return true; } @@ -103,7 +103,7 @@ public class ColorPicker16 : View /// private bool MoveRight (ICommandContext? commandContext) { - if (RaiseSelecting (commandContext) == true) + if (RaiseActivating (commandContext) == true) { return true; } @@ -119,7 +119,7 @@ public class ColorPicker16 : View /// private bool MoveUp (ICommandContext? commandContext) { - if (RaiseSelecting (commandContext) == true) + if (RaiseActivating (commandContext) == true) { return true; } @@ -195,7 +195,7 @@ public class ColorPicker16 : View AddCommand (Command.Up, (ctx) => MoveUp (ctx)); AddCommand (Command.Down, (ctx) => MoveDown (ctx)); - AddCommand (Command.Select, (ctx) => + AddCommand (Command.Activate, (ctx) => { var set = false; diff --git a/Terminal.Gui/Views/FileDialogs/FileDialog.cs b/Terminal.Gui/Views/FileDialogs/FileDialog.cs index 9ecfe23c4..5b8118acb 100644 --- a/Terminal.Gui/Views/FileDialogs/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialogs/FileDialog.cs @@ -194,8 +194,8 @@ public class FileDialog : Dialog, IDesignable Id = "_tableView" }; _tableView.CollectionNavigator = new FileDialogCollectionNavigator (this, _tableView); - _tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select); - _tableView.Selecting += OnTableViewSelecting; + _tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate); + _tableView.Activating += OnTableViewActivating; Style.TableStyle = _tableView.Style; ColumnStyle nameStyle = Style.TableStyle.GetOrCreateColumnStyle (0); @@ -1046,7 +1046,7 @@ public class FileDialog : Dialog, IDesignable } } - private void OnTableViewSelecting (object? sender, CommandEventArgs e) + private void OnTableViewActivating (object? sender, CommandEventArgs e) { // Only handle mouse clicks, not keyboard selections if (e.Context is not CommandContext { Binding.MouseEventArgs: { } mouseArgs }) diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs index b05f0b506..94f99ee47 100644 --- a/Terminal.Gui/Views/HexView.cs +++ b/Terminal.Gui/Views/HexView.cs @@ -57,7 +57,7 @@ public class HexView : View, IDesignable _leftSideHasFocus = true; _firstNibble = true; - AddCommand (Command.Select, HandleMouseClick); + AddCommand (Command.Activate, HandleMouseClick); AddCommand (Command.Left, () => MoveLeft ()); AddCommand (Command.Right, () => MoveRight ()); AddCommand (Command.Down, () => MoveDown (BytesPerLine)); @@ -100,9 +100,9 @@ public class HexView : View, IDesignable KeyBindings.Remove (Key.Space); KeyBindings.Remove (Key.Enter); - // The Select handler deals with both single and double clicks - MouseBindings.ReplaceCommands (MouseFlags.Button1Clicked, Command.Select); - MouseBindings.Add (MouseFlags.Button1DoubleClicked, Command.Select); + // The Activate handler deals with both single and double clicks + MouseBindings.ReplaceCommands (MouseFlags.Button1Clicked, Command.Activate); + MouseBindings.Add (MouseFlags.Button1DoubleClicked, Command.Activate); MouseBindings.Add (MouseFlags.WheeledUp, Command.ScrollUp); MouseBindings.Add (MouseFlags.WheeledDown, Command.ScrollDown); @@ -363,7 +363,7 @@ public class HexView : View, IDesignable return false; } - if (RaiseSelecting (commandContext) is true) + if (RaiseActivating (commandContext) is true) { return true; } diff --git a/Terminal.Gui/Views/Label.cs b/Terminal.Gui/Views/Label.cs index 512e961fc..39eeaa2b6 100644 --- a/Terminal.Gui/Views/Label.cs +++ b/Terminal.Gui/Views/Label.cs @@ -81,7 +81,7 @@ public class Label : View, IDesignable } /// - protected override bool OnSelecting (CommandEventArgs args) + protected override bool OnActivating (CommandEventArgs args) { // If Label can't focus and is clicked, invoke HotKey on next peer if (!CanFocus) @@ -89,7 +89,7 @@ public class Label : View, IDesignable return InvokeCommand (Command.HotKey, args.Context) == true; } - return base.OnSelecting (args); + return base.OnActivating (args); } /// diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index 453737c85..45d1aea8b 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -59,10 +59,10 @@ public class ListView : View, IDesignable // Things this view knows how to do // - AddCommand (Command.Up, ctx => RaiseSelecting (ctx) == true || MoveUp ()); - AddCommand (Command.Down, ctx => RaiseSelecting (ctx) == true || MoveDown ()); + AddCommand (Command.Up, ctx => RaiseActivating (ctx) == true || MoveUp ()); + AddCommand (Command.Down, ctx => RaiseActivating (ctx) == true || MoveDown ()); - // TODO: add RaiseSelecting to all of these + // TODO: add RaiseActivating to all of these AddCommand (Command.ScrollUp, () => ScrollVertical (-1)); AddCommand (Command.ScrollDown, () => ScrollVertical (1)); AddCommand (Command.PageUp, () => MovePageUp ()); @@ -85,9 +85,9 @@ public class ListView : View, IDesignable return OnOpenSelectedItem (); }); - // Select (Space key and single-click) - If markable, change mark and raise Select event + // Activate (Space key and single-click) - If markable, change mark and raise Activate event AddCommand ( - Command.Select, + Command.Activate, ctx => { if (!_allowsMarking) @@ -95,7 +95,7 @@ public class ListView : View, IDesignable return false; } - if (RaiseSelecting (ctx) == true) + if (RaiseActivating (ctx) == true) { return true; } @@ -103,7 +103,7 @@ public class ListView : View, IDesignable return MarkUnmarkSelectedItem (); }); - // Hotkey - If none set, select and raise Select event. SetFocus. - DO NOT raise Accept + // Hotkey - If none set, activate and raise Activate event. SetFocus. - DO NOT raise Accept AddCommand ( Command.HotKey, ctx => @@ -115,7 +115,7 @@ public class ListView : View, IDesignable SelectedItem = 0; - if (RaiseSelecting (ctx) == true) + if (RaiseActivating (ctx) == true) { return true; } @@ -151,8 +151,8 @@ public class ListView : View, IDesignable KeyBindings.Add (Key.End, Command.End); - // Key.Space is already bound to Command.Select; this gives us select then move down - KeyBindings.Add (Key.Space.WithShift, Command.Select, Command.Down); + // Key.Space is already bound to Command.Activate; this gives us activate then move down + KeyBindings.Add (Key.Space.WithShift, Command.Activate, Command.Down); // Use the form of Add that lets us pass context to the handler KeyBindings.Add (Key.A.WithCtrl, new KeyBinding ([Command.SelectAll], true)); diff --git a/Terminal.Gui/Views/NumericUpDown.cs b/Terminal.Gui/Views/NumericUpDown.cs index adb94d554..0fa64bff8 100644 --- a/Terminal.Gui/Views/NumericUpDown.cs +++ b/Terminal.Gui/Views/NumericUpDown.cs @@ -98,7 +98,7 @@ public class NumericUpDown : View where T : notnull } // BUGBUG: If this is uncommented, the numericupdown in a shortcut will not work - //if (RaiseSelecting (ctx) is true) + //if (RaiseActivating (ctx) is true) //{ // return true; //} @@ -120,7 +120,7 @@ public class NumericUpDown : View where T : notnull } // BUGBUG: If this is uncommented, the numericupdown in a shortcut will not work - //if (RaiseSelecting (ctx) is true) + //if (RaiseActivating (ctx) is true) //{ // return true; //} diff --git a/Terminal.Gui/Views/ScrollBar/ScrollBar.cs b/Terminal.Gui/Views/ScrollBar/ScrollBar.cs index e854bcc63..a76545702 100644 --- a/Terminal.Gui/Views/ScrollBar/ScrollBar.cs +++ b/Terminal.Gui/Views/ScrollBar/ScrollBar.cs @@ -517,18 +517,18 @@ public class ScrollBar : View, IOrientation, IDesignable // TODO: Change this to work OnMouseEvent with continuouse press and grab so it's continous. /// - protected override bool OnSelecting (CommandEventArgs args) + protected override bool OnActivating (CommandEventArgs args) { // Only handle mouse clicks if (args.Context is not CommandContext { Binding.MouseEventArgs: { } mouseArgs }) { - return base.OnSelecting (args); + return base.OnActivating (args); } // Check if the mouse click is a single click if (!mouseArgs.IsSingleClicked) { - return base.OnSelecting (args); + return base.OnActivating (args); } int sliderCenter; diff --git a/Terminal.Gui/Views/ScrollBar/ScrollSlider.cs b/Terminal.Gui/Views/ScrollBar/ScrollSlider.cs index d3d861ac2..a4d1a5f33 100644 --- a/Terminal.Gui/Views/ScrollBar/ScrollSlider.cs +++ b/Terminal.Gui/Views/ScrollBar/ScrollSlider.cs @@ -236,7 +236,7 @@ public class ScrollSlider : View, IOrientation, IDesignable OnScrolled (distance); Scrolled?.Invoke (this, new (in distance)); - RaiseSelecting (new CommandContext (Command.Select, this, new KeyBinding ([Command.Select], null, distance))); + RaiseActivating (new CommandContext (Command.Activate, this, new KeyBinding ([Command.Activate], null, distance))); } /// diff --git a/Terminal.Gui/Views/Selectors/FlagSelector.cs b/Terminal.Gui/Views/Selectors/FlagSelector.cs index c2c8c15f9..b98b92006 100644 --- a/Terminal.Gui/Views/Selectors/FlagSelector.cs +++ b/Terminal.Gui/Views/Selectors/FlagSelector.cs @@ -4,12 +4,12 @@ namespace Terminal.Gui.Views; // Click - Focus, Select (Toggle), and do NOT Accept the item under the mouse. // Not Focused: // HotKey - Restore Focus. Do NOT change Active. -// Item HotKey - Focus item. Select (Toggle) item. Do NOT Accept. +// Item HotKey - Focus item. Activate (Toggle) item. Do NOT Accept. // Focused: -// Space key - Select (Toggle) focused item. Do NOT Accept. -// Enter key - Select (Toggle) and Accept the focused item. +// Space key - Activate (Toggle) focused item. Do NOT Accept. +// Enter key - Activate (Toggle) and Accept the focused item. // HotKey - No-op. -// Item HotKey - Focus item, Select (Toggle), and do NOT Accept. +// Item HotKey - Focus item, Activate (Toggle), and do NOT Accept. /// /// Provides a user interface for displaying and selecting non-mutually-exclusive flags from a provided dictionary. @@ -31,7 +31,7 @@ public class FlagSelector : SelectorBase, IDesignable checkbox.CheckedStateChanging += OnCheckboxOnCheckedStateChanging; checkbox.CheckedStateChanged += OnCheckboxOnCheckedStateChanged; - checkbox.Selecting += OnCheckboxOnSelecting; + checkbox.Activating += OnCheckboxOnActivating; checkbox.Accepting += OnCheckboxOnAccepting; } @@ -76,7 +76,7 @@ public class FlagSelector : SelectorBase, IDesignable Value = newValue; } - private void OnCheckboxOnSelecting (object? sender, CommandEventArgs args) + private void OnCheckboxOnActivating (object? sender, CommandEventArgs args) { if (sender is not CheckBox checkbox) { @@ -85,13 +85,13 @@ public class FlagSelector : SelectorBase, IDesignable if (checkbox.CanFocus) { - // For Select, if the view is focusable and SetFocus succeeds, by defition, + // For Activate, if the view is focusable and SetFocus succeeds, by definition, // the event is handled. So return what SetFocus returns. checkbox.SetFocus (); } - // Selecting doesn't normally propogate, so we do it here - if (InvokeCommand (Command.Select, args.Context) is true) + // Activating doesn't normally propagate, so we do it here + if (InvokeCommand (Command.Activate, args.Context) is true) { // Do not return here; we want to toggle the checkbox state args.Handled = true; diff --git a/Terminal.Gui/Views/Selectors/OptionSelector.cs b/Terminal.Gui/Views/Selectors/OptionSelector.cs index ab4159cc3..6544e5da6 100644 --- a/Terminal.Gui/Views/Selectors/OptionSelector.cs +++ b/Terminal.Gui/Views/Selectors/OptionSelector.cs @@ -12,8 +12,8 @@ namespace Terminal.Gui.Views; // HotKey - Do NOT Restore Focus. Advance Active. Do NOT Accept. // Item HotKey - Do NOT Focus item. If item is not active, make Active. Do NOT Accept. // Focused: -// Space key - If focused item is Active, move focus to and Acivate next. Else, Select current. Do NOT Accept. -// Enter key - Select and Accept the focused item. +// Space key - If focused item is Active, move focus to and Acivate next. Else, Activate current. Do NOT Accept. +// Enter key - Activate and Accept the focused item. // HotKey - Restore Focus. Advance Active. Do NOT Accept. // Item HotKey - If item is not active, make Active. Do NOT Accept. @@ -43,14 +43,14 @@ public class OptionSelector : SelectorBase, IDesignable } if (!CanFocus) { - if (RaiseSelecting (args.Context) is true) + if (RaiseActivating (args.Context) is true) { return true; } } else if (!HasFocus && Value is null) { - if (RaiseSelecting (args.Context) is true) + if (RaiseActivating (args.Context) is true) { return true; } @@ -63,9 +63,9 @@ public class OptionSelector : SelectorBase, IDesignable } /// - protected override bool OnSelecting (CommandEventArgs args) + protected override bool OnActivating (CommandEventArgs args) { - if (base.OnSelecting (args) is true) + if (base.OnActivating (args) is true) { return true; } @@ -112,12 +112,12 @@ public class OptionSelector : SelectorBase, IDesignable checkbox.RadioStyle = true; - checkbox.Selecting += OnCheckboxOnSelecting; + checkbox.Activating += OnCheckboxOnActivating; checkbox.Accepting += OnCheckboxOnAccepting; } - private void OnCheckboxOnSelecting (object? sender, CommandEventArgs args) + private void OnCheckboxOnActivating (object? sender, CommandEventArgs args) { if (sender is not CheckBox checkbox) { @@ -148,8 +148,8 @@ public class OptionSelector : SelectorBase, IDesignable checkbox.SetFocus (); } - // Selecting doesn't normally propogate, so we do it here - if (InvokeCommand (Command.Select, args.Context) is true) + // Selecting doesn't normally propagate, so we do it here + if (InvokeCommand (Command.Activate, args.Context) is true) { // Do not return here; we want to toggle the checkbox state args.Handled = true; diff --git a/Terminal.Gui/Views/Selectors/SelectorBase.cs b/Terminal.Gui/Views/Selectors/SelectorBase.cs index 03b7ac2ba..6bee62aca 100644 --- a/Terminal.Gui/Views/Selectors/SelectorBase.cs +++ b/Terminal.Gui/Views/Selectors/SelectorBase.cs @@ -79,16 +79,16 @@ public abstract class SelectorBase : View, IOrientation if ((HasFocus || !CanFocus) && HotKey == keyCommandContext.Binding.Key?.NoAlt.NoCtrl.NoShift!) { - // It's this.HotKey OR Another View (Label?) forwarded the hotkey command to us - Act just like `Space` (Select) - return Focused?.InvokeCommand (Command.Select, args.Context) is true; + // It's this.HotKey OR Another View (Label?) forwarded the hotkey command to us - Act just like `Space` (Activate) + return Focused?.InvokeCommand (Command.Activate, args.Context) is true; } return base.OnHandlingHotKey (args); } /// - protected override bool OnSelecting (CommandEventArgs args) + protected override bool OnActivating (CommandEventArgs args) { - return base.OnSelecting (args); + return base.OnActivating (args); } private int? _value; diff --git a/Terminal.Gui/Views/Shortcut.cs b/Terminal.Gui/Views/Shortcut.cs index 87d0f9f89..307e5b610 100644 --- a/Terminal.Gui/Views/Shortcut.cs +++ b/Terminal.Gui/Views/Shortcut.cs @@ -248,14 +248,14 @@ public class Shortcut : View, IOrientation, IDesignable // Hotkey - AddCommand (Command.HotKey, DispatchCommand); - // Select (Space key or click) - - AddCommand (Command.Select, DispatchCommand); + // Activate (Space key or click) - + AddCommand (Command.Activate, DispatchCommand); } /// - /// Dispatches the Command in the (Raises Selected, then Accepting, then invoke the + /// Dispatches the Command in the (Raises Activating, then Accepting, then invoke the /// Action, if any). - /// Called when Command.Select, Accept, or HotKey has been invoked on this Shortcut. + /// Called when Command.Activate, Accept, or HotKey has been invoked on this Shortcut. /// /// /// @@ -273,18 +273,18 @@ public class Shortcut : View, IOrientation, IDesignable if (keyCommandContext?.Binding.Data != this) { // TODO: Optimize this to only do this if CommandView is custom (non View) - // Invoke Select on the CommandView to cause it to change state if it wants to + // Invoke Activate on the CommandView to cause it to change state if it wants to // If this causes CommandView to raise Accept, we eat it keyCommandContext = keyCommandContext!.Value with { Binding = keyCommandContext.Value.Binding with { Data = this } }; - Logging.Debug ($"{Title} ({commandContext?.Source?.Title}) - Invoking Select on CommandView ({CommandView.GetType ().Name})."); + Logging.Debug ($"{Title} ({commandContext?.Source?.Title}) - Invoking Activate on CommandView ({CommandView.GetType ().Name})."); - CommandView.InvokeCommand (Command.Select, keyCommandContext); + CommandView.InvokeCommand (Command.Activate, keyCommandContext); } - Logging.Debug ($"{Title} ({commandContext?.Source?.Title}) - RaiseSelecting ..."); + Logging.Debug ($"{Title} ({commandContext?.Source?.Title}) - RaiseActivating ..."); - if (RaiseSelecting (commandContext) is true) + if (RaiseActivating (commandContext) is true) { return true; } @@ -426,7 +426,7 @@ public class Shortcut : View, IOrientation, IDesignable } // Clean up old - _commandView.Selecting -= CommandViewOnSelecting; + _commandView.Activating -= CommandViewOnActivating; _commandView.Accepting -= CommandViewOnAccepted; Remove (_commandView); _commandView?.Dispose (); @@ -452,7 +452,7 @@ public class Shortcut : View, IOrientation, IDesignable Title = _commandView.Text; - _commandView.Selecting += CommandViewOnSelecting; + _commandView.Activating += CommandViewOnActivating; _commandView.Accepting += CommandViewOnAccepted; //ShowHide (); @@ -466,13 +466,13 @@ public class Shortcut : View, IOrientation, IDesignable e.Handled = true; } - void CommandViewOnSelecting (object? sender, CommandEventArgs e) + void CommandViewOnActivating (object? sender, CommandEventArgs e) { if ((e.Context is CommandContext keyCommandContext && keyCommandContext.Binding.Data != this) || e.Context is CommandContext) { // Forward command to ourselves - InvokeCommand (Command.Select, new ([Command.Select], null, this)); + InvokeCommand (Command.Activate, new ([Command.Activate], null, this)); } e.Handled = true; diff --git a/Terminal.Gui/Views/Slider/Slider.cs b/Terminal.Gui/Views/Slider/Slider.cs index 0535beff0..5c7a9f347 100644 --- a/Terminal.Gui/Views/Slider/Slider.cs +++ b/Terminal.Gui/Views/Slider/Slider.cs @@ -1426,7 +1426,7 @@ public class Slider : View, IOrientation AddCommand (Command.RightEnd, () => MoveEnd ()); AddCommand (Command.RightExtend, () => ExtendPlus ()); AddCommand (Command.LeftExtend, () => ExtendMinus ()); - AddCommand (Command.Select, () => Select ()); + AddCommand (Command.Activate, () => Select ()); AddCommand (Command.Accept, (ctx) => Accept (ctx)); SetKeyBindings (); @@ -1467,7 +1467,7 @@ public class Slider : View, IOrientation KeyBindings.Remove (Key.Enter); KeyBindings.Add (Key.Enter, Command.Accept); KeyBindings.Remove (Key.Space); - KeyBindings.Add (Key.Space, Command.Select); + KeyBindings.Add (Key.Space, Command.Activate); } private Dictionary> GetSetOptionDictionary () { return _setOptions.ToDictionary (e => e, e => _options [e]); } diff --git a/Terminal.Gui/Views/TabView/TabRow.cs b/Terminal.Gui/Views/TabView/TabRow.cs index 54dd618fa..0385624ce 100644 --- a/Terminal.Gui/Views/TabView/TabRow.cs +++ b/Terminal.Gui/Views/TabView/TabRow.cs @@ -24,7 +24,7 @@ internal class TabRow : View Visible = false, Text = Glyphs.RightArrow.ToString () }; - _rightScrollIndicator.Selecting += (s, e) => + _rightScrollIndicator.Activating += (s, e) => { _host.Tab_Selecting (s, e); }; @@ -37,7 +37,7 @@ internal class TabRow : View Visible = false, Text = Glyphs.LeftArrow.ToString () }; - _leftScrollIndicator.Selecting += (s, e) => + _leftScrollIndicator.Activating += (s, e) => { _host.Tab_Selecting (s, e); }; diff --git a/Terminal.Gui/Views/TabView/TabView.cs b/Terminal.Gui/Views/TabView/TabView.cs index b41ac7bb8..d9061e211 100644 --- a/Terminal.Gui/Views/TabView/TabView.cs +++ b/Terminal.Gui/Views/TabView/TabView.cs @@ -563,8 +563,8 @@ public class TabView : View if (maxWidth == 0) { tab.Visible = true; - tab.Selecting += Tab_Selecting!; - tab.Border!.Selecting += Tab_Selecting!; + tab.Activating += Tab_Selecting!; + tab.Border!.Activating += Tab_Selecting!; yield return tab; @@ -594,8 +594,8 @@ public class TabView : View // there is enough space! tab.Visible = true; - tab.Selecting += Tab_Selecting!; - tab.Border!.Selecting += Tab_Selecting!; + tab.Activating += Tab_Selecting!; + tab.Border!.Activating += Tab_Selecting!; yield return tab; @@ -655,8 +655,8 @@ public class TabView : View if (tab.Visible) { - tab.Selecting -= Tab_Selecting!; - tab.Border!.Selecting -= Tab_Selecting!; + tab.Activating -= Tab_Selecting!; + tab.Border!.Activating -= Tab_Selecting!; tab.Visible = false; } } @@ -665,8 +665,8 @@ public class TabView : View { foreach (Tab tabToRender in _tabLocations) { - tabToRender.Selecting -= Tab_Selecting!; - tabToRender.Border!.Selecting -= Tab_Selecting!; + tabToRender.Activating -= Tab_Selecting!; + tabToRender.Border!.Activating -= Tab_Selecting!; tabToRender.Visible = false; } diff --git a/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs b/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs index aaec4e9b5..e9b2da086 100644 --- a/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs +++ b/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs @@ -28,9 +28,9 @@ public abstract class CheckBoxTableSourceWrapperBase : ITableSource Wrapping = toWrap; this.tableView = tableView; - tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select); + tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate); - tableView.Selecting += TableView_Selecting; + tableView.Activating += TableView_Activating; tableView.CellToggled += TableView_CellToggled; } @@ -153,7 +153,7 @@ public abstract class CheckBoxTableSourceWrapperBase : ITableSource } #nullable enable - private void TableView_Selecting (object? sender, CommandEventArgs e) + private void TableView_Activating (object? sender, CommandEventArgs e) { // Only handle mouse clicks, not keyboard selections if (e.Context is not CommandContext { Binding.MouseEventArgs: { } mouseArgs }) diff --git a/Terminal.Gui/Views/TableView/TableSelection.cs b/Terminal.Gui/Views/TableView/TableSelection.cs index 2fe21f9cd..8b5ec0c8e 100644 --- a/Terminal.Gui/Views/TableView/TableSelection.cs +++ b/Terminal.Gui/Views/TableView/TableSelection.cs @@ -14,7 +14,7 @@ public class TableSelection } /// - /// True if the selection was made through and therefore should persist even + /// True if the selection was made through and therefore should persist even /// through keyboard navigation. /// public bool IsToggled { get; set; } diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs index 451636799..405b2a0f4 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -243,12 +243,12 @@ public class TableView : View, IDesignable AddCommand (Command.Accept, () => OnCellActivated (new (Table, SelectedColumn, SelectedRow))); AddCommand ( - Command.Select, // was Command.ToggleChecked + Command.Activate, // was Command.ToggleChecked ctx => { if (ToggleCurrentCellSelection () is true) { - return RaiseSelecting (ctx) is true; + return RaiseActivating (ctx) is true; } return false; @@ -461,7 +461,7 @@ public class TableView : View, IDesignable /// public event EventHandler CellActivated; - /// This event is raised when a cell is toggled (see + /// This event is raised when a cell is toggled (see public event EventHandler CellToggled; /// @@ -1574,7 +1574,7 @@ public class TableView : View, IDesignable /// Origin point for the selection in Y /// End point for the selection in X /// End point for the selection in Y - /// True if selection is result of + /// True if selection is result of /// private TableSelection CreateTableSelection (int pt1X, int pt1Y, int pt2X, int pt2Y, bool toggle = false) { diff --git a/Terminal.Gui/Views/TableView/TreeTableSource.cs b/Terminal.Gui/Views/TableView/TreeTableSource.cs index 8eccb4203..999c2b01f 100644 --- a/Terminal.Gui/Views/TableView/TreeTableSource.cs +++ b/Terminal.Gui/Views/TableView/TreeTableSource.cs @@ -42,7 +42,7 @@ public class TreeTableSource : IEnumerableTableSource, IDisposable where T _tableView = table; _tree = tree; _tableView.KeyDown += Table_KeyPress; - _tableView.Selecting += Table_Selecting; + _tableView.Activating += Table_Activating; List colList = subsequentColumns.Keys.ToList (); colList.Insert (0, firstColumnName); @@ -56,7 +56,7 @@ public class TreeTableSource : IEnumerableTableSource, IDisposable where T public void Dispose () { _tableView.KeyDown -= Table_KeyPress; - _tableView.Selecting -= Table_Selecting; + _tableView.Activating -= Table_Activating; _tree.Dispose (); } @@ -169,7 +169,7 @@ public class TreeTableSource : IEnumerableTableSource, IDisposable where T } #nullable enable - private void Table_Selecting (object? sender, CommandEventArgs e) + private void Table_Activating (object? sender, CommandEventArgs e) { // Only handle mouse clicks, not keyboard selections if (e.Context is not CommandContext { Binding.MouseEventArgs: { } mouseArgs }) diff --git a/Terminal.Gui/Views/TreeView/TreeView.cs b/Terminal.Gui/Views/TreeView/TreeView.cs index a0ca872c1..92ee00cd1 100644 --- a/Terminal.Gui/Views/TreeView/TreeView.cs +++ b/Terminal.Gui/Views/TreeView/TreeView.cs @@ -291,7 +291,7 @@ public class TreeView : View, ITreeView where T : class } ); - AddCommand (Command.Select, ActivateSelectedObjectIfAny); + AddCommand (Command.Activate, ActivateSelectedObjectIfAny); AddCommand (Command.Accept, ActivateSelectedObjectIfAny); // Default keybindings for this view @@ -317,7 +317,7 @@ public class TreeView : View, ITreeView where T : class KeyBindings.Add (Key.A.WithCtrl, Command.SelectAll); KeyBindings.Remove (ObjectActivationKey); - KeyBindings.Add (ObjectActivationKey, Command.Select); + KeyBindings.Add (ObjectActivationKey, Command.Activate); } /// diff --git a/Tests/UnitTests/View/Mouse/MouseTests.cs b/Tests/UnitTests/View/Mouse/MouseTests.cs index f2c17e186..b01dacaf6 100644 --- a/Tests/UnitTests/View/Mouse/MouseTests.cs +++ b/Tests/UnitTests/View/Mouse/MouseTests.cs @@ -106,7 +106,7 @@ public class MouseTests : TestsAllViews [InlineData (MouseFlags.Button2Clicked)] [InlineData (MouseFlags.Button3Clicked)] [InlineData (MouseFlags.Button4Clicked)] - public void WantContinuousButtonPressed_True_Button_Clicked_Raises_Selecting (MouseFlags clicked) + public void WantContinuousButtonPressed_True_Button_Clicked_Raises_Activating (MouseFlags clicked) { MouseEventArgs me = new (); @@ -117,13 +117,13 @@ public class MouseTests : TestsAllViews WantContinuousButtonPressed = true }; - var selectingCount = 0; + var activatingCount = 0; - view.Selecting += (s, e) => selectingCount++; + view.Activating += (s, e) => activatingCount++; me.Flags = clicked; view.NewMouseEvent (me); - Assert.Equal (1, selectingCount); + Assert.Equal (1, activatingCount); view.Dispose (); diff --git a/Tests/UnitTests/Views/ButtonTests.cs b/Tests/UnitTests/Views/ButtonTests.cs index 6e3690eee..e3eda089e 100644 --- a/Tests/UnitTests/Views/ButtonTests.cs +++ b/Tests/UnitTests/Views/ButtonTests.cs @@ -285,9 +285,9 @@ public class ButtonTests (ITestOutputHelper output) WantContinuousButtonPressed = true }; - var selectingCount = 0; + var activatingCount = 0; - button.Selecting += (s, e) => selectingCount++; + button.Activating += (s, e) => activatingCount++; var acceptedCount = 0; button.Accepting += (s, e) => @@ -299,19 +299,19 @@ public class ButtonTests (ITestOutputHelper output) me = new (); me.Flags = pressed; button.NewMouseEvent (me); - Assert.Equal (0, selectingCount); + Assert.Equal (0, activatingCount); Assert.Equal (0, acceptedCount); me = new (); me.Flags = released; button.NewMouseEvent (me); - Assert.Equal (0, selectingCount); + Assert.Equal (0, activatingCount); Assert.Equal (0, acceptedCount); me = new (); me.Flags = clicked; button.NewMouseEvent (me); - Assert.Equal (1, selectingCount); + Assert.Equal (1, activatingCount); Assert.Equal (1, acceptedCount); button.Dispose (); @@ -341,23 +341,23 @@ public class ButtonTests (ITestOutputHelper output) e.Handled = true; }; - var selectingCount = 0; + var activatingCount = 0; - button.Selecting += (s, e) => + button.Activating += (s, e) => { - selectingCount++; + activatingCount++; e.Handled = true; }; me.Flags = pressed; button.NewMouseEvent (me); Assert.Equal (0, acceptedCount); - Assert.Equal (0, selectingCount); + Assert.Equal (0, activatingCount); me.Flags = released; button.NewMouseEvent (me); Assert.Equal (0, acceptedCount); - Assert.Equal (0, selectingCount); + Assert.Equal (0, activatingCount); button.Dispose (); } diff --git a/Tests/UnitTests/Views/CheckBoxTests.cs b/Tests/UnitTests/Views/CheckBoxTests.cs index a14d1c45d..8b55a0567 100644 --- a/Tests/UnitTests/Views/CheckBoxTests.cs +++ b/Tests/UnitTests/Views/CheckBoxTests.cs @@ -271,10 +271,10 @@ public class CheckBoxTests (ITestOutputHelper output) ckb.CheckedState = initialState; - ckb.Selecting += OnActivating; + ckb.Activating += OnActivating; Assert.Equal (initialState, ckb.CheckedState); - bool? ret = ckb.InvokeCommand (Command.Select); + bool? ret = ckb.InvokeCommand (Command.Activate); Assert.True (ret); Assert.True (checkedInvoked); Assert.Equal (initialState, ckb.CheckedState); diff --git a/Tests/UnitTests/Views/ShortcutTests.cs b/Tests/UnitTests/Views/ShortcutTests.cs index 045644b9d..fc7936a3c 100644 --- a/Tests/UnitTests/Views/ShortcutTests.cs +++ b/Tests/UnitTests/Views/ShortcutTests.cs @@ -69,9 +69,9 @@ public class ShortcutTests public void MouseClick_Default_CommandView_Raises_Accepted_Selected_Correctly ( int mouseX, int expectedCommandViewAccepted, - int expectedCommandViewSelected, + int expectedCommandViewActivated, int expectedShortcutAccepted, - int expectedShortcutSelected + int expectedShortcutActivated ) { Application.Begin (new Runnable ()); @@ -85,13 +85,13 @@ public class ShortcutTests var commandViewAcceptCount = 0; shortcut.CommandView.Accepting += (s, e) => { commandViewAcceptCount++; }; - var commandViewSelectCount = 0; - shortcut.CommandView.Selecting += (s, e) => { commandViewSelectCount++; }; + var commandViewActivatingCount = 0; + shortcut.CommandView.Activating += (s, e) => { commandViewActivatingCount++; }; var shortcutAcceptCount = 0; shortcut.Accepting += (s, e) => { shortcutAcceptCount++; }; var shortcutSelectCount = 0; - shortcut.Selecting += (s, e) => { shortcutSelectCount++; }; + shortcut.Activating += (s, e) => { shortcutSelectCount++; }; Application.TopRunnableView.Add (shortcut); Application.TopRunnableView.SetRelativeLayout (new (100, 100)); @@ -105,9 +105,9 @@ public class ShortcutTests }); Assert.Equal (expectedShortcutAccepted, shortcutAcceptCount); - Assert.Equal (expectedShortcutSelected, shortcutSelectCount); + Assert.Equal (expectedShortcutActivated, shortcutSelectCount); Assert.Equal (expectedCommandViewAccepted, commandViewAcceptCount); - Assert.Equal (expectedCommandViewSelected, commandViewSelectCount); + Assert.Equal (expectedCommandViewActivated, commandViewActivatingCount); Application.TopRunnableView.Dispose (); Application.ResetState (true); @@ -202,24 +202,24 @@ public class ShortcutTests var checkboxAccepted = 0; shortcut.CommandView.Accepting += (s, e) => { checkboxAccepted++; }; - var checkboxSelected = 0; - shortcut.CommandView.Selecting += (s, e) => + var checkboxActivated = 0; + shortcut.CommandView.Activating += (s, e) => { if (e.Handled) { return; } - checkboxSelected++; + checkboxActivated++; }; Application.TopRunnableView.Add (shortcut); Application.TopRunnableView.SetRelativeLayout (new (100, 100)); Application.TopRunnableView.LayoutSubViews (); - var selected = 0; - shortcut.Selecting += (s, e) => + var activatingCount = 0; + shortcut.Activating += (s, e) => { - selected++; + activatingCount++; }; var accepted = 0; @@ -237,9 +237,9 @@ public class ShortcutTests }); Assert.Equal (expectedAccepted, accepted); - Assert.Equal (expectedAccepted, selected); + Assert.Equal (expectedAccepted, activatingCount); Assert.Equal (expectedCheckboxAccepted, checkboxAccepted); - Assert.Equal (expectedCheckboxAccepted, checkboxSelected); + Assert.Equal (expectedCheckboxAccepted, checkboxActivated); Application.TopRunnableView.Dispose (); Application.ResetState (true); @@ -278,7 +278,7 @@ public class ShortcutTests shortcut.Accepting += (s, e) => accepted++; var selected = 0; - shortcut.Selecting += (s, e) => selected++; + shortcut.Activating += (s, e) => selected++; Application.RaiseKeyDownEvent (key); diff --git a/Tests/UnitTests/Views/TableViewTests.cs b/Tests/UnitTests/Views/TableViewTests.cs index 791501a08..ec3fed7ed 100644 --- a/Tests/UnitTests/Views/TableViewTests.cs +++ b/Tests/UnitTests/Views/TableViewTests.cs @@ -3048,7 +3048,7 @@ A B C dt.Rows.Add (1, 2, 3, 4, 5, 6); tableView.MultiSelect = true; - tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select); + tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate); Point selectedCell = tableView.GetAllSelectedCells ().Single (); Assert.Equal (0, selectedCell.X); @@ -3120,7 +3120,7 @@ A B C dt.Rows.Add (1, 2, 3, 4, 5, 6); tableView.FullRowSelect = true; tableView.MultiSelect = true; - tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select); + tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate); // Toggle Select Cell 0,0 tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.Space }); @@ -3160,7 +3160,7 @@ A B C dt.Rows.Add (1, 2, 3, 4, 5, 6); dt.Rows.Add (1, 2, 3, 4, 5, 6); tableView.MultiSelect = true; - tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select); + tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate); // Make a square selection tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.ShiftMask | KeyCode.CursorDown }); @@ -3201,7 +3201,7 @@ A B C dt.Rows.Add (1, 2, 3, 4, 5, 6); dt.Rows.Add (1, 2, 3, 4, 5, 6); tableView.MultiSelect = true; - tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select); + tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate); // Make first square selection (0,0 to 1,1) tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.ShiftMask | KeyCode.CursorDown }); diff --git a/Tests/UnitTestsParallelizable/ViewBase/Keyboard/KeyBindingsTests.cs b/Tests/UnitTestsParallelizable/ViewBase/Keyboard/KeyBindingsTests.cs index 588654222..18d9849b3 100644 --- a/Tests/UnitTestsParallelizable/ViewBase/Keyboard/KeyBindingsTests.cs +++ b/Tests/UnitTestsParallelizable/ViewBase/Keyboard/KeyBindingsTests.cs @@ -159,7 +159,7 @@ public class KeyBindingsTests view.HandlingHotKey += (s, e) => hotKeyRaised = true; view.Accepting += (s, e) => acceptRaised = true; - view.Selecting += (s, e) => selectRaised = true; + view.Activating += (s, e) => selectRaised = true; Assert.Equal (KeyCode.T, view.HotKey); Assert.True (app.Keyboard.RaiseKeyDownEvent (Key.T)); diff --git a/Tests/UnitTestsParallelizable/ViewBase/Mouse/MouseEventRoutingTests.cs b/Tests/UnitTestsParallelizable/ViewBase/Mouse/MouseEventRoutingTests.cs index b72cd4c84..2aecf9e9f 100644 --- a/Tests/UnitTestsParallelizable/ViewBase/Mouse/MouseEventRoutingTests.cs +++ b/Tests/UnitTestsParallelizable/ViewBase/Mouse/MouseEventRoutingTests.cs @@ -194,8 +194,8 @@ public class MouseEventRoutingTests (ITestOutputHelper output) superView.Add (subView); - int selectingCount = 0; - subView.Selecting += (_, _) => selectingCount++; + int activatingCount = 0; + subView.Activating += (_, _) => activatingCount++; MouseEventArgs mouseEvent = new () { @@ -207,7 +207,7 @@ public class MouseEventRoutingTests (ITestOutputHelper output) subView.NewMouseEvent (mouseEvent); // Assert - Assert.Equal (1, selectingCount); + Assert.Equal (1, activatingCount); subView.Dispose (); superView.Dispose (); @@ -395,7 +395,7 @@ public class MouseEventRoutingTests (ITestOutputHelper output) }; bool selectingCalled = false; - view.Selecting += (_, _) => { selectingCalled = true; }; + view.Activating += (_, _) => { selectingCalled = true; }; MouseEventArgs mouseEvent = new () { @@ -467,8 +467,8 @@ public class MouseEventRoutingTests (ITestOutputHelper output) superView.Add (view); - int selectingCount = 0; - view.Selecting += (_, _) => selectingCount++; + int activatingCount = 0; + view.Activating += (_, _) => activatingCount++; MouseEventArgs mouseEvent = new () { @@ -480,7 +480,7 @@ public class MouseEventRoutingTests (ITestOutputHelper output) view.NewMouseEvent (mouseEvent); // Assert - Assert.Equal (1, selectingCount); + Assert.Equal (1, activatingCount); view.Dispose (); superView.Dispose (); diff --git a/Tests/UnitTestsParallelizable/ViewBase/Mouse/MouseTests.cs b/Tests/UnitTestsParallelizable/ViewBase/Mouse/MouseTests.cs index 1659b40fb..8d5a94b4e 100644 --- a/Tests/UnitTestsParallelizable/ViewBase/Mouse/MouseTests.cs +++ b/Tests/UnitTestsParallelizable/ViewBase/Mouse/MouseTests.cs @@ -11,7 +11,7 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews { var testView = new View (); - Assert.Contains (MouseFlags.Button1Clicked, testView.MouseBindings.GetAllFromCommands (Command.Select)); + Assert.Contains (MouseFlags.Button1Clicked, testView.MouseBindings.GetAllFromCommands (Command.Activate)); // Assert.Contains (MouseFlags.Button1DoubleClicked, testView.MouseBindings.GetAllFromCommands (Command.Accept)); Assert.Equal (5, testView.MouseBindings.GetBindings ().Count ()); @@ -48,7 +48,7 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews [InlineData (false, false, 1)] [InlineData (true, false, 1)] [InlineData (true, true, 1)] - public void MouseClick_Raises_Selecting (bool canFocus, bool setFocus, int expectedSelectingCount) + public void MouseClick_Raises_Activating (bool canFocus, bool setFocus, int expectedActivatingCount) { var superView = new View { CanFocus = true, Height = 1, Width = 15 }; var focusedView = new View { CanFocus = true, Width = 1, Height = 1 }; @@ -66,12 +66,12 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews testView.SetFocus (); } - var selectingCount = 0; - testView.Selecting += (sender, args) => selectingCount++; + var activatingCount = 0; + testView.Activating += (sender, args) => activatingCount++; testView.NewMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }); Assert.True (superView.HasFocus); - Assert.Equal (expectedSelectingCount, selectingCount); + Assert.Equal (expectedActivatingCount, activatingCount); } [Theory] diff --git a/Tests/UnitTestsParallelizable/ViewBase/ViewCommandTests.cs b/Tests/UnitTestsParallelizable/ViewBase/ViewCommandTests.cs index 00b9dea4b..1d720cf6b 100644 --- a/Tests/UnitTestsParallelizable/ViewBase/ViewCommandTests.cs +++ b/Tests/UnitTestsParallelizable/ViewBase/ViewCommandTests.cs @@ -242,11 +242,11 @@ public class ViewCommandTests #endregion Accepted tests - #region OnSelect/Select tests + #region OnActivating/Activating tests [Theory] [CombinatorialData] - public void Select_Command_Raises_SetsFocus (bool canFocus) + public void Activate_Command_Raises_SetsFocus (bool canFocus) { var view = new ViewEventTester { @@ -256,76 +256,76 @@ public class ViewCommandTests Assert.Equal (canFocus, view.CanFocus); Assert.False (view.HasFocus); - view.InvokeCommand (Command.Select); + view.InvokeCommand (Command.Activate); - Assert.Equal (1, view.OnSelectingCount); + Assert.Equal (1, view.OnActivatingCount); - Assert.Equal (1, view.SelectingCount); + Assert.Equal (1, view.ActivatingCount); Assert.Equal (canFocus, view.HasFocus); } [Fact] - public void Select_Command_Handle_OnSelecting_NoEvent () + public void Activate_Command_Handle_OnActivating_NoEvent () { var view = new ViewEventTester (); Assert.False (view.HasFocus); - view.HandleOnSelecting = true; - Assert.True (view.InvokeCommand (Command.Select)); + view.HandleOnActivating = true; + Assert.True (view.InvokeCommand (Command.Activate)); - Assert.Equal (1, view.OnSelectingCount); + Assert.Equal (1, view.OnActivatingCount); - Assert.Equal (0, view.SelectingCount); + Assert.Equal (0, view.ActivatingCount); } [Fact] - public void Select_Handle_Event_OnSelecting_Returns_True () + public void Activate_Command_Handle_Event_OnActivating_Returns_True () { var view = new View (); - var selectingInvoked = false; + var activatingInvoked = false; - view.Selecting += ViewOnSelect; + view.Activating += ViewOnActivating; - bool? ret = view.InvokeCommand (Command.Select); + bool? ret = view.InvokeCommand (Command.Activate); Assert.True (ret); - Assert.True (selectingInvoked); + Assert.True (activatingInvoked); return; - void ViewOnSelect (object? sender, CommandEventArgs e) + void ViewOnActivating (object? sender, CommandEventArgs e) { - selectingInvoked = true; + activatingInvoked = true; e.Handled = true; } } [Fact] - public void Select_Command_Invokes_Selecting_Event () + public void Activate_Command_Invokes_Activating_Event () { var view = new View (); - var selecting = false; + var activating = false; - view.Selecting += ViewOnSelecting; + view.Activating += ViewOnActivating; - view.InvokeCommand (Command.Select); - Assert.True (selecting); + view.InvokeCommand (Command.Activate); + Assert.True (activating); return; - void ViewOnSelecting (object? sender, CommandEventArgs e) { selecting = true; } + void ViewOnActivating (object? sender, CommandEventArgs e) { activating = true; } } [Fact] - public void MouseClick_Invokes_Select_Command () + public void MouseClick_Invokes_Activate_Command () { var view = new ViewEventTester (); view.NewMouseEvent (new () { Flags = MouseFlags.Button1Clicked, Position = Point.Empty, View = view }); - Assert.Equal (1, view.OnSelectingCount); + Assert.Equal (1, view.OnActivatingCount); } - #endregion OnSelect/Select tests + #endregion OnActivating/Activating tests #region OnHotKey/HotKey tests @@ -390,25 +390,25 @@ public class ViewCommandTests Id = "viewEventTester"; CanFocus = true; - Accepting += (s, a) => + Accepting += (_, a) => { a.Handled = HandleAccepted; AcceptedCount++; }; - HandlingHotKey += (s, a) => + HandlingHotKey += (_, a) => { a.Handled = HandleHandlingHotKey; HandlingHotKeyCount++; }; - Selecting += (s, a) => + Activating += (_, a) => { - a.Handled = HandleSelecting; - SelectingCount++; + a.Handled = HandleActivating; + ActivatingCount++; }; - CommandNotBound += (s, a) => + CommandNotBound += (_, a) => { a.Handled = HandleCommandNotBound; CommandNotBoundCount++; @@ -443,18 +443,18 @@ public class ViewCommandTests public bool HandleHandlingHotKey { get; set; } - public int OnSelectingCount { get; set; } - public int SelectingCount { get; set; } - public bool HandleOnSelecting { get; set; } - public bool HandleSelecting { get; set; } + public int OnActivatingCount { get; set; } + public int ActivatingCount { get; set; } + public bool HandleOnActivating { get; set; } + public bool HandleActivating { get; set; } /// - protected override bool OnSelecting (CommandEventArgs args) + protected override bool OnActivating (CommandEventArgs args) { - OnSelectingCount++; + OnActivatingCount++; - return HandleOnSelecting; + return HandleOnActivating; } public int OnCommandNotBoundCount { get; set; } diff --git a/Tests/UnitTestsParallelizable/Views/AllViewsTests.cs b/Tests/UnitTestsParallelizable/Views/AllViewsTests.cs index 2aa9a09c0..ae01594cd 100644 --- a/Tests/UnitTestsParallelizable/Views/AllViewsTests.cs +++ b/Tests/UnitTestsParallelizable/Views/AllViewsTests.cs @@ -146,15 +146,15 @@ public class AllViewsTests (ITestOutputHelper output) : TestsAllViews designable.EnableForDesign (); } - var selectingCount = 0; - view.Selecting += (s, e) => selectingCount++; + var activatingCount = 0; + view.Activating += (s, e) => activatingCount++; var acceptedCount = 0; view.Accepting += (s, e) => { acceptedCount++; }; - if (view.InvokeCommand (Command.Select) == true) + if (view.InvokeCommand (Command.Activate) == true) { - Assert.Equal (1, selectingCount); + Assert.Equal (1, activatingCount); Assert.Equal (0, acceptedCount); } view?.Dispose (); @@ -178,15 +178,15 @@ public class AllViewsTests (ITestOutputHelper output) : TestsAllViews designable.EnableForDesign (); } - var selectingCount = 0; - view.Selecting += (s, e) => selectingCount++; + var activatingCount = 0; + view.Activating += (s, e) => activatingCount++; var acceptingCount = 0; view.Accepting += (s, e) => { acceptingCount++; }; if (view.InvokeCommand (Command.Accept) == true) { - Assert.Equal (0, selectingCount); + Assert.Equal (0, activatingCount); Assert.Equal (1, acceptingCount); } view?.Dispose (); diff --git a/Tests/UnitTestsParallelizable/Views/CheckBoxTests.cs b/Tests/UnitTestsParallelizable/Views/CheckBoxTests.cs index 047f2d8db..5778e8b0f 100644 --- a/Tests/UnitTestsParallelizable/Views/CheckBoxTests.cs +++ b/Tests/UnitTestsParallelizable/Views/CheckBoxTests.cs @@ -22,7 +22,7 @@ public class CheckBoxTests () ckb.CheckedStateChanging += (s, e) => checkedStateChangingCount++; var selectCount = 0; - ckb.Selecting += (s, e) => selectCount++; + ckb.Activating += (s, e) => selectCount++; var acceptCount = 0; ckb.Accepting += (s, e) => acceptCount++; @@ -250,7 +250,7 @@ public class CheckBoxTests () checkBox.CheckedStateChanging += (s, e) => checkedStateChangingCount++; var selectCount = 0; - checkBox.Selecting += (s, e) => selectCount++; + checkBox.Activating += (s, e) => selectCount++; var acceptCount = 0; checkBox.Accepting += (s, e) => acceptCount++; @@ -292,7 +292,7 @@ public class CheckBoxTests () checkBox.CheckedStateChanging += (s, e) => checkedStateChangingCount++; var selectCount = 0; - checkBox.Selecting += (s, e) => selectCount++; + checkBox.Activating += (s, e) => selectCount++; var acceptCount = 0; diff --git a/Tests/UnitTestsParallelizable/Views/ShortcutTests.cs b/Tests/UnitTestsParallelizable/Views/ShortcutTests.cs index 2e6bfe7fa..a653ed433 100644 --- a/Tests/UnitTestsParallelizable/Views/ShortcutTests.cs +++ b/Tests/UnitTestsParallelizable/Views/ShortcutTests.cs @@ -484,7 +484,7 @@ public class ShortcutTests }; var selected = 0; - shortcut.Selecting += (s, e) => selected++; + shortcut.Activating += (s, e) => selected++; app.Keyboard.RaiseKeyDownEvent (key); diff --git a/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs b/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs index bd49aa1d5..5da63a69d 100644 --- a/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs +++ b/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs @@ -49,7 +49,7 @@ public class TextFieldTests (ITestOutputHelper output) : FakeDriverBase { TextField tf = new (); - tf.Selecting += (sender, args) => Assert.Fail ("Selected should not be raied."); + tf.Activating += (sender, args) => Assert.Fail ("Activating should not be raised."); Runnable top = new (); top.Add (tf); @@ -64,15 +64,15 @@ public class TextFieldTests (ITestOutputHelper output) : FakeDriverBase { TextField tf = new (); - var selectingCount = 0; - tf.Selecting += (sender, args) => selectingCount++; + var activatingCount = 0; + tf.Activating += (sender, args) => activatingCount++; Runnable top = new (); top.Add (tf); tf.SetFocus (); top.NewKeyDownEvent (Key.Enter); - Assert.Equal (0, selectingCount); + Assert.Equal (0, activatingCount); top.Dispose (); } diff --git a/docfx/docs/View.md b/docfx/docs/View.md index f9c8d2138..006ab7e5f 100644 --- a/docfx/docs/View.md +++ b/docfx/docs/View.md @@ -127,7 +127,7 @@ See the [Command Deep Dive](command.md). - [View.AddCommand](~/api/Terminal.Gui.ViewBase.View.yml) - Declares commands the View supports - [View.InvokeCommand](~/api/Terminal.Gui.ViewBase.View.yml) - Invokes a command -- [Command](~/api/Terminal.Gui.Input.Command.yml) enum - Standard set of commands (Accept, Select, HotKey, etc.) +- [Command](~/api/Terminal.Gui.Input.Command.yml) enum - Standard set of commands (Accept, Activate, HotKey, etc.) ### Input Handling @@ -228,8 +228,8 @@ Events: - `HasFocusChanged` - After focus changes - `Accepting` - When Command.Accept is invoked (typically Enter key) - `Accepted` - After Command.Accept completes -- `Selecting` - When Command.Select is invoked (typically Space or mouse click) -- `Selected` - After Command.Select completes +- `Activating` - When Command.Activate is invoked (typically Space or mouse click) +- `Activated` - After Command.Activate completes ### Scrolling @@ -340,7 +340,7 @@ view.AddCommand (Command.Accept, () => view.KeyBindings.Add (Key.Enter, Command.Accept); // Bind a mouse action to the command -view.MouseBindings.Add (MouseFlags.Button1Clicked, Command.Select); +view.MouseBindings.Add (MouseFlags.Button1Clicked, Command.Activate); ``` ### Input @@ -610,7 +610,7 @@ Color? result = Application.Create() if (result is { }) { - Console.WriteLine($"Selected: {result}"); + Console.WriteLine($"Activated: {result}"); } ``` diff --git a/docfx/docs/command-diagrams.md b/docfx/docs/command-diagrams.md new file mode 100644 index 000000000..08bc17fa7 --- /dev/null +++ b/docfx/docs/command-diagrams.md @@ -0,0 +1,101 @@ +### Level 1: Basic View Command Flow + +This diagram shows the fundamental command invocation flow within a single view, demonstrating the Cancellable Work Pattern with pre-events (e.g., `Activating`, `Accepting`) and the command handler execution. + +```mermaid +flowchart TD + input["User input (key/mouse)"] --> invoke["View.InvokeCommand(command)"] + invoke --> |Command.Activate| act_pre["OnActivating + Activating handlers"] + invoke --> |Command.Accept| acc_pre["OnAccepting + Accepting handlers"] + + act_pre --> |canceled| act_stop["Stop"] + act_pre --> |not canceled| act_handler["Execute command handler"] + act_handler --> act_done["Complete (returns bool?)"] + + acc_pre --> |canceled| acc_stop["Stop"] + acc_pre --> |not canceled| acc_handler["Execute command handler"] + acc_handler --> acc_prop["Propagate to default button/superview if unhandled"] + acc_prop --> acc_done["Complete (returns bool?)"] +``` + +**Key Points:** +- Commands follow the Cancellable Work Pattern: pre-event → virtual method → event → handler +- `OnActivating`/`OnAccepting` or event handlers can cancel via `args.Cancel = true` +- Command handlers return `bool?`: `null` (no handler), `false` (executed but unhandled), `true` (handled/canceled) +- `Command.Activate` is handled locally (no propagation) +- `Command.Accept` may propagate (see Level 2) + +### Level 2: Accept Propagation with Button.IsDefault + +This diagram shows how `Command.Accept` propagates through the view hierarchy, including the special case where a default button intercepts the command even when invoked from another view. + +```mermaid +flowchart TD + input2["User input (Enter)"] --> tf_accept["TextField.InvokeCommand(Accept)"] + tf_accept --> tf_pre["TextField OnAccepting + Accepting"] + tf_pre --> |canceled| tf_stop["Stop"] + tf_pre --> |not canceled| tf_default_check["Find sibling IsDefault button"] + + tf_default_check --> |found| call_default["Invoke default Button.Accept"] + call_default --> btn_pre["Button OnAccepting + Accepting"] + btn_pre --> btn_done["Handled → return true"] + btn_done --> tf_result1["Handled by default button"] + + tf_default_check --> |not found/returned null| call_super["Propagate to SuperView (Dialog)"] + call_super --> dlg_pre["Dialog OnAccepting + Accepting"] + dlg_pre --> dlg_done["Handled/propagated result"] +``` + +**Key Points:** +- `Command.Accept` checks for a sibling `Button` with `IsDefault = true` in the `SuperView` +- If found and not the source view, the default button handles the command first +- If unhandled or no default button, command propagates to `SuperView` +- `SuperView` (e.g., `Dialog`) can handle accept to close or trigger actions +- This enables Enter key to activate default buttons from any focused view + +### Level 3: Complete Flow with Shortcut, MenuBar, and Menu + +This diagram illustrates the complete command flow in a complex hierarchical scenario involving `Shortcut`, `MenuBar`, `Menu`, and `MenuItem`, showing how commands route through multiple views and how `Accepted` events propagate back up the hierarchy. + +```mermaid +flowchart TD + sc_header["=== Scenario 1: Shortcut Activation (Alt+F) ==="] + sc_header --> sc_input["Alt+F pressed"] + sc_input --> sc_find["Shortcut finds MenuBarItem"] + sc_find --> sc_hotkey["MenuBarItem.InvokeCommand(HotKey)"] + sc_hotkey --> sc_pre["OnHandlingHotKey + HandlingHotKey"] + sc_pre --> sc_focus["MenuBarItem sets focus"] + sc_focus --> sc_show["MenuBar shows popover for MenuBarItem"] + + sc_show --> nav_header["=== Scenario 2: Menu Navigation (Arrow Keys) ==="] + nav_header --> nav_input["Arrow keys pressed"] + nav_input --> nav_activate["MenuItem.InvokeCommand(Activate)"] + nav_activate --> nav_pre["MenuItem OnActivating + Activating"] + nav_pre --> |canceled| nav_stop["Stop"] + nav_pre --> |not canceled| nav_focus["MenuItem sets focus"] + nav_focus --> nav_changed["Menu.SelectedMenuItemChanged raised"] + nav_changed --> nav_bar["MenuBar.OnSelectedMenuItemChanged"] + nav_bar --> nav_done["Update popover visibility if needed"] + + nav_done --> acc_header["=== Scenario 3: Accept Menu Item (Enter) ==="] + acc_header --> acc_input["Enter pressed on MenuItem"] + acc_input --> acc_pre["MenuItem OnAccepting + Accepting"] + acc_pre --> |canceled| acc_stop["Stop"] + acc_pre --> |has action| acc_exec["Execute menu item action"] + acc_exec --> acc_accepted["MenuItem.RaiseAccepted"] + acc_accepted --> acc_menu["Menu.OnAccepted propagates"] + acc_menu --> acc_bar["MenuBar.OnAccepted"] + acc_bar --> acc_close["MenuBar hides popover, deactivates"] + + acc_pre --> |has submenu| acc_sub["Propagate to parent Menu.Accept"] + acc_sub --> acc_popover["Show submenu popover"] + acc_popover --> acc_submenu_done["Submenu displayed"] +``` + +**Key Points:** +- **Scenario 1 (HotKey)**: Shortcut activates menu bar item via `Command.HotKey`, which sets focus and triggers MenuBar to show the popover +- **Scenario 2 (Activate)**: Arrow keys navigate menu items via `Command.Activate`, which is handled locally but raises `SelectedMenuItemChanged` for MenuBar coordination +- **Scenario 3 (Accept)**: Enter key executes menu items via `Command.Accept`, followed by `Accepted` event propagating up (MenuItem → Menu → MenuBar) to close menus +- `Command.Activate` doesn't propagate but uses view-specific event (`SelectedMenuItemChanged`) for hierarchical coordination +- `Accepted` is a post-event (not part of Cancellable Work Pattern pre-event phase) that signals action completion +- MenuBar uses `SelectedMenuItemChanged` to manage popover visibility, demonstrating current workaround for lack of generic `Activate` propagation diff --git a/docfx/docs/command.md b/docfx/docs/command.md index 41d6ca1cd..a0953bfcb 100644 --- a/docfx/docs/command.md +++ b/docfx/docs/command.md @@ -8,19 +8,38 @@ ## Overview -The `Command` system in Terminal.Gui provides a standardized framework for defining and executing actions that views can perform, such as selecting items, accepting input, or navigating content. Implemented primarily through the `View.Command` APIs, this system integrates tightly with input handling (e.g., keyboard and mouse events) and leverages the *Cancellable Work Pattern* to ensure extensibility, cancellation, and decoupling. Central to this system are the `Selecting` and `Accepting` events, which encapsulate common user interactions: `Selecting` for changing a view’s state or preparing it for interaction (e.g., toggling a checkbox, focusing a menu item), and `Accepting` for confirming an action or state (e.g., executing a menu command, submitting a dialog). +The `Command` system in Terminal.Gui provides a standardized framework for defining and executing actions that views can perform, such as selecting items, accepting input, or navigating content. Implemented primarily through the `View.Command` APIs, this system integrates tightly with input handling (e.g., keyboard and mouse events) and leverages the *Cancellable Work Pattern* to ensure extensibility, cancellation, and decoupling. Central to this system are the `Activating` and `Accepting` events, which encapsulate common user interactions: `Activating` for changing a view’s state or preparing it for interaction (e.g., toggling a checkbox, focusing a menu item), and `Accepting` for confirming an action or state (e.g., executing a menu command, submitting a dialog). -This deep dive explores the `Command` and `View.Command` APIs, focusing on the `Selecting` and `Accepting` concepts, their implementation, and their propagation behavior. It critically evaluates the need for additional events (`Selected`/`Accepted`) and the propagation of `Selecting` events, drawing on insights from `Menu`, `MenuItemv2`, `MenuBar`, `CheckBox`, and `FlagSelector`. These implementations highlight the system’s application in hierarchical (menus) and stateful (checkboxes, flag selectors) contexts. The document reflects the current implementation, including the `Cancel` property in `CommandEventArgs` and local handling of `Command.Select`. An appendix briefly summarizes proposed changes from a filed issue to rename `Command.Select` to `Command.Activate`, replace `Cancel` with `Handled`, and introduce a propagation mechanism, addressing limitations in the current system. +This deep dive explores the `Command` and `View.Command` APIs, focusing on the `Activating` and `Accepting` concepts, their implementation, and their propagation behavior. It critically evaluates the need for additional events (`Selected`/`Accepted`) and the propagation of `Activating` events, drawing on insights from `Menu`, `MenuItemv2`, `MenuBar`, `CheckBox`, and `FlagSelector`. These implementations highlight the system’s application in hierarchical (menus) and stateful (checkboxes, flag selectors) contexts. The document reflects the current implementation, including the `Cancel` property in `CommandEventArgs` and local handling of `Command.Activate`. An appendix briefly summarizes proposed changes from a filed issue noting the rename from `Command.Select` to `Command.Activate` has been completed, replace `Cancel` with `Handled`, and introduce a propagation mechanism, addressing limitations in the current system. + + +This diagram shows the fundamental command invocation flow within a single view, demonstrating the Cancellable Work Pattern with pre-events (e.g., `Activating`, `Accepting`) and the command handler execution. + +```mermaid +flowchart TD + input["User input (key/mouse)"] --> invoke["View.InvokeCommand(command)"] + invoke --> |Command.Activate| act_pre["OnActivating + Activating handlers"] + invoke --> |Command.Accept| acc_pre["OnAccepting + Accepting handlers"] + + act_pre --> |canceled| act_stop["Stop"] + act_pre --> |not canceled| act_handler["Execute command handler"] + act_handler --> act_done["Complete (returns bool?)"] + + acc_pre --> |canceled| acc_stop["Stop"] + acc_pre --> |not canceled| acc_handler["Execute command handler"] + acc_handler --> acc_prop["Propagate to default button/superview if unhandled"] + acc_prop --> acc_done["Complete (returns bool?)"] +``` ## Overview of the Command System -The `Command` system in Terminal.Gui defines a set of standard actions via the `Command` enum (e.g., `Command.Select`, `Command.Accept`, `Command.HotKey`, `Command.StartOfPage`). These actions are triggered by user inputs (e.g., key presses, mouse clicks) or programmatically, enabling consistent view interactions. +The `Command` system in Terminal.Gui defines a set of standard actions via the `Command` enum (e.g., `Command.Activate`, `Command.Accept`, `Command.HotKey`, `Command.StartOfPage`). These actions are triggered by user inputs (e.g., key presses, mouse clicks) or programmatically, enabling consistent view interactions. ### Key Components - **Command Enum**: Defines actions like `Select` (state change or interaction preparation), `Accept` (action confirmation), `HotKey` (hotkey activation), and others (e.g., `StartOfPage` for navigation). - **Command Handlers**: Views register handlers using `View.AddCommand`, specifying a `CommandImplementation` delegate that returns `bool?` (`null`: no command executed; `false`: executed but not handled; `true`: handled or canceled). - **Command Routing**: Commands are invoked via `View.InvokeCommand`, executing the handler or raising `CommandNotBound` if no handler exists. -- **Cancellable Work Pattern**: Command execution uses events (e.g., `Selecting`, `Accepting`) and virtual methods (e.g., `OnSelecting`, `OnAccepting`) for modification or cancellation, with `Cancel` indicating processing should stop. +- **Cancellable Work Pattern**: Command execution uses events (e.g., `Activating`, `Accepting`) and virtual methods (e.g., `OnActivating`, `OnAccepting`) for modification or cancellation, with `Cancel` indicating processing should stop. ### Role in Terminal.Gui The `Command` system bridges user input and view behavior, enabling: @@ -43,9 +62,9 @@ Views register commands using `View.AddCommand`, associating a `Command` with a private void SetupCommands() { AddCommand(Command.Accept, RaiseAccepting); - AddCommand(Command.Select, ctx => + AddCommand(Command.Activate, ctx => { - if (RaiseSelecting(ctx) is true) + if (RaiseActivating(ctx) is true) { return true; } @@ -88,8 +107,8 @@ public bool? InvokeCommand(Command command, ICommandContext? ctx) ``` ### Command Routing -Most commands route directly to the target view. `Command.Select` and `Command.Accept` have special routing: -- `Command.Select`: Handled locally, with no propagation to superviews, relying on view-specific events (e.g., `SelectedMenuItemChanged` in `Menu`) for hierarchical coordination. +Most commands route directly to the target view. `Command.Activate` and `Command.Accept` have special routing: +- `Command.Activate`: Handled locally, with no propagation to superviews, relying on view-specific events (e.g., `SelectedMenuItemChanged` in `Menu`) for hierarchical coordination. - `Command.Accept`: Propagates to a default button (if `IsDefault = true`), superview, or `SuperMenuItem` (in menus). **Example**: `Command.Accept` in `RaiseAccepting`: @@ -122,38 +141,38 @@ protected bool? RaiseAccepting(ICommandContext? ctx) } ``` -## The Selecting and Accepting Concepts +## The Activating and Accepting Concepts -The `Selecting` and `Accepting` events, along with their corresponding commands (`Command.Select`, `Command.Accept`), are designed to handle the most common user interactions with views: -- **Selecting**: Changing a view’s state or preparing it for further interaction, such as highlighting an item in a list, toggling a checkbox, or focusing a menu item. +The `Activating` and `Accepting` events, along with their corresponding commands (`Command.Activate`, `Command.Accept`), are designed to handle the most common user interactions with views: +- **Activating**: Changing a view’s state or preparing it for further interaction, such as highlighting an item in a list, toggling a checkbox, or focusing a menu item. - **Accepting**: Confirming an action or state, such as submitting a form, activating a button, or finalizing a selection. These concepts are opinionated, reflecting Terminal.Gui’s view that most UI interactions can be modeled as either state changes/preparation (selecting) or action confirmations (accepting). Below, we explore each concept, their implementation, use cases, and propagation behavior, using `Cancel` to reflect the current implementation. -### Selecting -- **Definition**: `Selecting` represents a user action that changes a view’s state or prepares it for further interaction, such as selecting an item in a `ListView`, toggling a `CheckBox`, or focusing a `MenuItemv2`. It is associated with `Command.Select`, typically triggered by a spacebar press, single mouse click, navigation keys (e.g., arrow keys), or mouse enter (e.g., in menus). -- **Event**: The `Selecting` event is raised by `RaiseSelecting`, allowing external code to modify or cancel the state change. -- **Virtual Method**: `OnSelecting` enables subclasses to preprocess or cancel the action. +### Activating +- **Definition**: `Activating` represents a user action that changes a view’s state or prepares it for further interaction, such as selecting an item in a `ListView`, toggling a `CheckBox`, or focusing a `MenuItemv2`. It is associated with `Command.Activate`, typically triggered by a spacebar press, single mouse click, navigation keys (e.g., arrow keys), or mouse enter (e.g., in menus). +- **Event**: The `Activating` event is raised by `RaiseActivating`, allowing external code to modify or cancel the state change. +- **Virtual Method**: `OnActivating` enables subclasses to preprocess or cancel the action. - **Implementation**: ```csharp - protected bool? RaiseSelecting(ICommandContext? ctx) + protected bool? RaiseActivating(ICommandContext? ctx) { CommandEventArgs args = new() { Context = ctx }; - if (OnSelecting(args) || args.Cancel) + if (OnActivating(args) || args.Cancel) { return true; } - Selecting?.Invoke(this, args); - return Selecting is null ? null : args.Cancel; + Activating?.Invoke(this, args); + return Activating is null ? null : args.Cancel; } ``` - **Default Behavior**: Sets focus if `CanFocus` is true (via `SetupCommands`). - - **Cancellation**: `args.Cancel` or `OnSelecting` returning `true` halts the command. + - **Cancellation**: `args.Cancel` or `OnActivating` returning `true` halts the command. - **Context**: `ICommandContext` provides invocation details. - **Use Cases**: - - **ListView**: Selecting an item (e.g., via arrow keys or mouse click) raises `Selecting` to update the highlighted item. - - **CheckBox**: Toggling the checked state (e.g., via spacebar) raises `Selecting` to change the state, as seen in the `AdvanceAndSelect` method: + - **ListView**: Activating an item (e.g., via arrow keys or mouse click) raises `Activating` to update the highlighted item. + - **CheckBox**: Toggling the checked state (e.g., via spacebar) raises `Activating` to change the state, as seen in the `AdvanceAndSelect` method: ```csharp private bool? AdvanceAndSelect(ICommandContext? commandContext) { @@ -162,15 +181,15 @@ These concepts are opinionated, reflecting Terminal.Gui’s view that most UI in { return true; } - if (RaiseSelecting(commandContext) is true) + if (RaiseActivating(commandContext) is true) { return true; } return commandContext?.Command == Command.HotKey ? cancelled : cancelled is false; } ``` - - **OptionSelector**: Selecting an OpitonSelector option raises `Selecting` to update the selected option. - - **Menu** and **MenuBar**: Selecting a `MenuItemv2` (e.g., via mouse enter or arrow keys) sets focus, tracked by `SelectedMenuItem` and raising `SelectedMenuItemChanged`: + - **OptionSelector**: Activating an OpitonSelector option raises `Activating` to update the selected option. + - **Menu** and **MenuBar**: Activating a `MenuItemv2` (e.g., via mouse enter or arrow keys) sets focus, tracked by `SelectedMenuItem` and raising `SelectedMenuItemChanged`: ```csharp protected override void OnFocusedChanged(View? previousFocused, View? focused) { @@ -179,11 +198,11 @@ These concepts are opinionated, reflecting Terminal.Gui’s view that most UI in RaiseSelectedMenuItemChanged(SelectedMenuItem); } ``` - - **FlagSelector**: Selecting a `CheckBox` subview toggles a flag, updating the `Value` property and raising `ValueChanged`, though it incorrectly triggers `Accepting`: + - **FlagSelector**: Activating a `CheckBox` subview toggles a flag, updating the `Value` property and raising `ValueChanged`, though it incorrectly triggers `Accepting`: ```csharp - checkbox.Selecting += (sender, args) => + checkbox.Activating += (sender, args) => { - if (RaiseSelecting(args.Context) is true) + if (RaiseActivating(args.Context) is true) { args.Cancel = true; return; @@ -194,9 +213,9 @@ These concepts are opinionated, reflecting Terminal.Gui’s view that most UI in } }; ``` - - **Views without State**: For views like `Button`, `Selecting` typically sets focus but does not change state, making it less relevant. + - **Views without State**: For views like `Button`, `Activating` typically sets focus but does not change state, making it less relevant. -- **Propagation**: `Command.Select` is handled locally by the target view. If the command is unhandled (`null` or `false`), processing stops without propagating to the superview or other views. This is evident in `Menu`, where `SelectedMenuItemChanged` is used for hierarchical coordination, and in `CheckBox` and `FlagSelector`, where state changes are internal. +- **Propagation**: `Command.Activate` is handled locally by the target view. If the command is unhandled (`null` or `false`), processing stops without propagating to the superview or other views. This is evident in `Menu`, where `SelectedMenuItemChanged` is used for hierarchical coordination, and in `CheckBox` and `FlagSelector`, where state changes are internal. ### Accepting - **Definition**: `Accepting` represents a user action that confirms or finalizes a view’s state or triggers an action, such as submitting a dialog, activating a button, or confirming a selection in a list. It is associated with `Command.Accept`, typically triggered by the Enter key or double-click. @@ -224,7 +243,7 @@ These concepts are opinionated, reflecting Terminal.Gui’s view that most UI in ```csharp AddCommand(Command.Accept, RaiseAccepting); ``` - - **FlagSelector**: Pressing Enter raises `Accepting` to confirm the current `Value`, though its subview `Selecting` handler incorrectly triggers `Accepting`, which should be reserved for parent-level confirmation. + - **FlagSelector**: Pressing Enter raises `Accepting` to confirm the current `Value`, though its subview `Activating` handler incorrectly triggers `Accepting`, which should be reserved for parent-level confirmation. - **Dialog**: `Accepting` on a default button closes the dialog or triggers an action. - **Propagation**: `Command.Accept` propagates to: @@ -271,39 +290,39 @@ These concepts are opinionated, reflecting Terminal.Gui’s view that most UI in ``` ### Key Differences -| Aspect | Selecting | Accepting | +| Aspect | Activating | Accepting | |--------|-----------|-----------| | **Purpose** | Change view state or prepare for interaction (e.g., focus menu item, toggle checkbox, select list item) | Confirm action or state (e.g., execute menu command, submit, activate) | | **Trigger** | Spacebar, single click, navigation keys, mouse enter | Enter, double-click | -| **Event** | `Selecting` | `Accepting` | -| **Virtual Method** | `OnSelecting` | `OnAccepting` | +| **Event** | `Activating` | `Accepting` | +| **Virtual Method** | `OnActivating` | `OnAccepting` | | **Propagation** | Local to the view | Propagates to default button, superview, or SuperMenuItem (in menus) | | **Use Cases** | `Menu`, `MenuBar`, `CheckBox`, `FlagSelector`, `ListView`, `Button` | `Menu`, `MenuBar`, `CheckBox`, `FlagSelector`, `Button`, `ListView`, `Dialog` | | **State Dependency** | Often stateful, but includes focus for stateless views | May be stateless (triggers action) | -### Critical Evaluation: Selecting vs. Accepting -The distinction between `Selecting` and `Accepting` is clear in theory: -- `Selecting` is about state changes or preparatory actions, such as choosing an item in a `ListView` or toggling a `CheckBox`. +### Critical Evaluation: Activating vs. Accepting +The distinction between `Activating` and `Accepting` is clear in theory: +- `Activating` is about state changes or preparatory actions, such as choosing an item in a `ListView` or toggling a `CheckBox`. - `Accepting` is about finalizing an action, such as submitting a selection or activating a button. However, practical challenges arise: -- **Overlapping Triggers**: In `ListView`, pressing Enter might both select an item (`Selecting`) and confirm it (`Accepting`), depending on the interaction model, potentially confusing developers. Similarly, in `Menu`, navigation (e.g., arrow keys) triggers `Selecting`, while Enter triggers `Accepting`, but the overlap in user intent can blur the lines. -- **Stateless Views**: For views like `Button` or `MenuItemv2`, `Selecting` is limited to setting focus, which dilutes its purpose as a state-changing action and may confuse developers expecting a more substantial state change. -- **Propagation Limitations**: The local handling of `Command.Select` restricts hierarchical coordination. For example, `MenuBar` relies on `SelectedMenuItemChanged` to manage `PopoverMenu` visibility, which is view-specific and not generalizable. This highlights a need for a propagation mechanism that maintains subview-superview decoupling. -- **FlagSelector Design Flaw**: In `FlagSelector`, the `CheckBox.Selecting` handler incorrectly triggers both `Selecting` and `Accepting`, conflating state changes (toggling flags) with action confirmation (submitting the flag set). This violates the intended separation and requires a design fix to ensure `Selecting` is limited to subview state changes and `Accepting` is reserved for parent-level confirmation. +- **Overlapping Triggers**: In `ListView`, pressing Enter might both select an item (`Activating`) and confirm it (`Accepting`), depending on the interaction model, potentially confusing developers. Similarly, in `Menu`, navigation (e.g., arrow keys) triggers `Activating`, while Enter triggers `Accepting`, but the overlap in user intent can blur the lines. +- **Stateless Views**: For views like `Button` or `MenuItemv2`, `Activating` is limited to setting focus, which dilutes its purpose as a state-changing action and may confuse developers expecting a more substantial state change. +- **Propagation Limitations**: The local handling of `Command.Activate` restricts hierarchical coordination. For example, `MenuBar` relies on `SelectedMenuItemChanged` to manage `PopoverMenu` visibility, which is view-specific and not generalizable. This highlights a need for a propagation mechanism that maintains subview-superview decoupling. +- **FlagSelector Design Flaw**: In `FlagSelector`, the `CheckBox.Activating` handler incorrectly triggers both `Activating` and `Accepting`, conflating state changes (toggling flags) with action confirmation (submitting the flag set). This violates the intended separation and requires a design fix to ensure `Activating` is limited to subview state changes and `Accepting` is reserved for parent-level confirmation. -**Recommendation**: Enhance documentation to clarify the `Selecting`/`Accepting` model: -- Define `Selecting` as state changes or interaction preparation (e.g., item selection, toggling, focusing) and `Accepting` as action confirmations (e.g., submission, activation). -- Explicitly note that `Command.Select` may set focus in stateless views (e.g., `Button`, `MenuItemv2`) but is primarily for state changes. -- Address `FlagSelector`’s conflation by refactoring its `Selecting` handler to separate state changes from confirmation. +**Recommendation**: Enhance documentation to clarify the `Activating`/`Accepting` model: +- Define `Activating` as state changes or interaction preparation (e.g., item selection, toggling, focusing) and `Accepting` as action confirmations (e.g., submission, activation). +- Explicitly note that `Command.Activate` may set focus in stateless views (e.g., `Button`, `MenuItemv2`) but is primarily for state changes. +- Address `FlagSelector`’s conflation by refactoring its `Activating` handler to separate state changes from confirmation. ## Evaluating Selected/Accepted Events -The need for `Selected` and `Accepted` events is under consideration, with `Accepted` showing utility in specific views (`Menu`, `MenuBar`) but not universally required across all views. These events would serve as post-events, notifying that a `Selecting` or `Accepting` action has completed, similar to other *Cancellable Work Pattern* post-events like `ClearedViewport` in `View.Draw` or `OrientationChanged` in `OrientationHelper`. +The need for `Selected` and `Accepted` events is under consideration, with `Accepted` showing utility in specific views (`Menu`, `MenuBar`) but not universally required across all views. These events would serve as post-events, notifying that a `Activating` or `Accepting` action has completed, similar to other *Cancellable Work Pattern* post-events like `ClearedViewport` in `View.Draw` or `OrientationChanged` in `OrientationHelper`. ### Need for Selected/Accepted Events - **Selected Event**: - - **Purpose**: A `Selected` event would notify that a `Selecting` action has completed, indicating that a state change or preparatory action (e.g., a new item highlighted, a checkbox toggled) has taken effect. + - **Purpose**: A `Selected` event would notify that a `Activating` action has completed, indicating that a state change or preparatory action (e.g., a new item highlighted, a checkbox toggled) has taken effect. - **Use Cases**: - **Menu** and **MenuBar**: Notify when a new `MenuItemv2` is focused, currently handled by the `SelectedMenuItemChanged` event, which tracks focus changes: ```csharp @@ -365,15 +384,15 @@ The need for `Selected` and `Accepted` events is under consideration, with `Acce }; ``` - **ListView**: Notify when a new item is selected, typically handled by `SelectedItemChanged` or similar custom events. - - **Button**: Less relevant, as `Selecting` typically only sets focus, and no state change occurs to warrant a `Selected` notification. + - **Button**: Less relevant, as `Activating` typically only sets focus, and no state change occurs to warrant a `Selected` notification. - **Current Approach**: Views like `Menu`, `CheckBox`, and `FlagSelector` use custom events (`SelectedMenuItemChanged`, `CheckedStateChanged`, `ValueChanged`) to signal state changes, bypassing a generic `Selected` event. These view-specific events provide context (e.g., the selected `MenuItemv2`, the new `CheckedState`, or the updated `Value`) that a generic `Selected` event would struggle to convey without additional complexity. - **Pros**: - A standardized `Selected` event could unify state change notifications across views, reducing the need for custom events in some cases. - - Aligns with the *Cancellable Work Pattern*’s post-event phase, providing a consistent way to react to completed `Selecting` actions. + - Aligns with the *Cancellable Work Pattern*’s post-event phase, providing a consistent way to react to completed `Activating` actions. - Could simplify scenarios where external code needs to monitor state changes without subscribing to view-specific events. - **Cons**: - Overlaps with existing view-specific events, which are more contextually rich (e.g., `CheckedStateChanged` provides the new `CheckState`, whereas `Selected` would need additional data). - - Less relevant for stateless views like `Button`, where `Selecting` only sets focus, leading to inconsistent usage across view types. + - Less relevant for stateless views like `Button`, where `Activating` only sets focus, leading to inconsistent usage across view types. - Adds complexity to the base `View` class, potentially bloating the API for a feature not universally needed. - Requires developers to handle generic `Selected` events with less specific information, which could lead to more complex event handling logic compared to targeted view-specific events. - **Context Insight**: The use of `SelectedMenuItemChanged` in `Menu` and `MenuBar`, `CheckedStateChanged` in `CheckBox`, and `ValueChanged` in `FlagSelector` suggests that view-specific events are preferred for their specificity and context. These events are tailored to the view’s state (e.g., `MenuItemv2` instance, `CheckState`, or `Value`), making them more intuitive for developers than a generic `Selected` event. The absence of a `Selected` event in the current implementation indicates that it hasn’t been necessary for most use cases, as view-specific events adequately cover state change notifications. @@ -404,7 +423,7 @@ The need for `Selected` and `Accepted` events is under consideration, with `Acce } ``` - **CheckBox**: Could notify that the current `CheckedState` was confirmed (e.g., in a dialog context), though this is not currently implemented, as `Accepting` suffices for confirmation without a post-event. - - **FlagSelector**: Could notify that the current `Value` was confirmed, but this is not implemented, and the incorrect triggering of `Accepting` by subview `Selecting` complicates its use. + - **FlagSelector**: Could notify that the current `Value` was confirmed, but this is not implemented, and the incorrect triggering of `Accepting` by subview `Activating` complicates its use. - **Button**: Could notify that the button was activated, typically handled by a custom event like `Clicked`. - **ListView**: Could notify that a selection was confirmed (e.g., Enter pressed), often handled by custom events. - **Dialog**: Could notify that an action was completed (e.g., OK button clicked), useful for hierarchical scenarios. @@ -432,15 +451,15 @@ The need for `Selected` and `Accepted` events is under consideration, with `Acce **Recommendation**: Avoid adding `Selected` or `Accepted` events to the base `View` class for now. Instead: - Continue using view-specific events (e.g., `Menu.SelectedMenuItemChanged`, `CheckBox.CheckedStateChanged`, `FlagSelector.ValueChanged`, `ListView.SelectedItemChanged`, `Button.Clicked`) for their contextual specificity and clarity. - Maintain and potentially formalize the use of `Accepted` in views like `Menu`, `MenuBar`, and `Dialog`, tracking its utility to determine if broader adoption in a base class like `Bar` or `Runnable` is warranted. -- If `Selected` or `Accepted` events are added in the future, ensure they fire only when their respective events (`Selecting`, `Accepting`) are not canceled (i.e., `args.Cancel` is `false`), maintaining consistency with the *Cancellable Work Pattern*’s post-event phase. +- If `Selected` or `Accepted` events are added in the future, ensure they fire only when their respective events (`Activating`, `Accepting`) are not canceled (i.e., `args.Cancel` is `false`), maintaining consistency with the *Cancellable Work Pattern*’s post-event phase. -## Propagation of Selecting +## Propagation of Activating -The current implementation of `Command.Select` is local, but `MenuBar` requires propagation to manage `PopoverMenu` visibility, highlighting a limitation in the system’s ability to support hierarchical coordination without view-specific mechanisms. +The current implementation of `Command.Activate` is local, but `MenuBar` requires propagation to manage `PopoverMenu` visibility, highlighting a limitation in the system’s ability to support hierarchical coordination without view-specific mechanisms. ### Current Behavior -- **Selecting**: `Command.Select` is handled locally by the target view, with no propagation to the superview or other views. If the command is unhandled (returns `null` or `false`), processing stops without further routing. - - **Rationale**: `Selecting` is typically view-specific, as state changes (e.g., highlighting a `ListView` item, toggling a `CheckBox`) or preparatory actions (e.g., focusing a `MenuItemv2`) are internal to the view. This is evident in `CheckBox`, where state toggling is self-contained: +- **Activating**: `Command.Activate` is handled locally by the target view, with no propagation to the superview or other views. If the command is unhandled (returns `null` or `false`), processing stops without further routing. + - **Rationale**: `Activating` is typically view-specific, as state changes (e.g., highlighting a `ListView` item, toggling a `CheckBox`) or preparatory actions (e.g., focusing a `MenuItemv2`) are internal to the view. This is evident in `CheckBox`, where state toggling is self-contained: ```csharp private bool? AdvanceAndSelect(ICommandContext? commandContext) { @@ -449,7 +468,7 @@ The current implementation of `Command.Select` is local, but `MenuBar` requires { return true; } - if (RaiseSelecting(commandContext) is true) + if (RaiseActivating(commandContext) is true) { return true; } @@ -457,7 +476,7 @@ The current implementation of `Command.Select` is local, but `MenuBar` requires } ``` - **Context Across Views**: - - In `Menu`, `Selecting` sets focus and raises `SelectedMenuItemChanged` to track changes, but this is a view-specific mechanism: + - In `Menu`, `Activating` sets focus and raises `SelectedMenuItemChanged` to track changes, but this is a view-specific mechanism: ```csharp protected override void OnFocusedChanged(View? previousFocused, View? focused) { @@ -476,9 +495,9 @@ The current implementation of `Command.Select` is local, but `MenuBar` requires } } ``` - - In `CheckBox` and `FlagSelector`, `Selecting` is local, with state changes (e.g., `CheckedState`, `Value`) handled internally or via view-specific events (`CheckedStateChanged`, `ValueChanged`), requiring no superview involvement. - - In `ListView`, `Selecting` updates the highlighted item locally, with no need for propagation in typical use cases. - - In `Button`, `Selecting` sets focus, which is inherently local. + - In `CheckBox` and `FlagSelector`, `Activating` is local, with state changes (e.g., `CheckedState`, `Value`) handled internally or via view-specific events (`CheckedStateChanged`, `ValueChanged`), requiring no superview involvement. + - In `ListView`, `Activating` updates the highlighted item locally, with no need for propagation in typical use cases. + - In `Button`, `Activating` sets focus, which is inherently local. - **Accepting**: `Command.Accept` propagates to a default button (if present), the superview, or a `SuperMenuItem` (in menus), enabling hierarchical handling. - **Rationale**: `Accepting` often involves actions that affect the broader UI context (e.g., closing a dialog, executing a menu command), requiring coordination with parent views. This is evident in `Menu`’s propagation to `SuperMenuItem` and `MenuBar`’s handling of `Accepted`: @@ -497,16 +516,16 @@ The current implementation of `Command.Select` is local, but `MenuBar` requires } ``` -### Should Selecting Propagate? -The local handling of `Command.Select` is sufficient for many views, but `MenuBar`’s need to manage `PopoverMenu` visibility highlights a gap in the current design, where hierarchical coordination relies on view-specific events like `SelectedMenuItemChanged`. +### Should Activating Propagate? +The local handling of `Command.Activate` is sufficient for many views, but `MenuBar`’s need to manage `PopoverMenu` visibility highlights a gap in the current design, where hierarchical coordination relies on view-specific events like `SelectedMenuItemChanged`. - **Arguments For Propagation**: - **Hierarchical Coordination**: In `MenuBar`, propagation would allow the menu bar to react to `MenuItemv2` selections (e.g., focusing a menu item via arrow keys or mouse enter) to show or hide popovers, streamlining the interaction model. Without propagation, `MenuBar` depends on `SelectedMenuItemChanged`, which is specific to `Menu` and not reusable for other hierarchical components. - - **Consistency with Accepting**: `Command.Accept`’s propagation model supports hierarchical actions (e.g., dialog submission, menu command execution), suggesting that `Command.Select` could benefit from a similar approach to enable broader UI coordination, particularly in complex views like menus or dialogs. + - **Consistency with Accepting**: `Command.Accept`’s propagation model supports hierarchical actions (e.g., dialog submission, menu command execution), suggesting that `Command.Activate` could benefit from a similar approach to enable broader UI coordination, particularly in complex views like menus or dialogs. - **Future-Proofing**: Propagation could support other hierarchical components, such as `TabView` (coordinating tab selection) or nested dialogs (tracking subview state changes), enhancing the `Command` system’s flexibility for future use cases. - **Arguments Against Propagation**: - - **Locality of State Changes**: `Selecting` is inherently view-specific in most cases, as state changes (e.g., `CheckBox` toggling, `ListView` item highlighting) or preparatory actions (e.g., `Button` focus) are internal to the view. Propagating `Selecting` events could flood superviews with irrelevant events, requiring complex filtering logic. For example, `CheckBox` and `FlagSelector` operate effectively without propagation: + - **Locality of State Changes**: `Activating` is inherently view-specific in most cases, as state changes (e.g., `CheckBox` toggling, `ListView` item highlighting) or preparatory actions (e.g., `Button` focus) are internal to the view. Propagating `Activating` events could flood superviews with irrelevant events, requiring complex filtering logic. For example, `CheckBox` and `FlagSelector` operate effectively without propagation: ```csharp checkbox.CheckedStateChanged += (sender, args) => { @@ -529,7 +548,7 @@ The local handling of `Command.Select` is sufficient for many views, but `MenuBa Value = newValue; }; ``` - - **Performance and Complexity**: Propagation increases event handling overhead and complicates the API, as superviews must process or ignore `Selecting` events. This could lead to performance issues in deeply nested view hierarchies or views with frequent state changes. + - **Performance and Complexity**: Propagation increases event handling overhead and complicates the API, as superviews must process or ignore `Activating` events. This could lead to performance issues in deeply nested view hierarchies or views with frequent state changes. - **Existing Alternatives**: View-specific events like `SelectedMenuItemChanged`, `CheckedStateChanged`, and `ValueChanged` already provide mechanisms for superview coordination, negating the need for generic propagation in many cases. For instance, `MenuBar` uses `SelectedMenuItemChanged` to manage popovers, albeit in a view-specific way: ```csharp protected override void OnSelectedMenuItemChanged(MenuItemv2? selected) @@ -541,40 +560,40 @@ The local handling of `Command.Select` is sufficient for many views, but `MenuBa } ``` Similarly, `CheckBox` and `FlagSelector` use `CheckedStateChanged` and `ValueChanged` to notify superviews or external code of state changes, which is sufficient for most scenarios. - - **Semantics of `Cancel`**: Propagation would occur only if `args.Cancel` is `false`, implying an unhandled selection, which is counterintuitive since `Selecting` typically completes its action (e.g., setting focus or toggling a state) within the view. This could confuse developers expecting propagation to occur for all `Selecting` events. + - **Semantics of `Cancel`**: Propagation would occur only if `args.Cancel` is `false`, implying an unhandled selection, which is counterintuitive since `Activating` typically completes its action (e.g., setting focus or toggling a state) within the view. This could confuse developers expecting propagation to occur for all `Activating` events. -- **Context Insight**: The `MenuBar` implementation demonstrates a clear need for propagation to manage `PopoverMenu` visibility, as it must react to `MenuItemv2` selections (e.g., focus changes) across its submenu hierarchy. The reliance on `SelectedMenuItemChanged` works but is specific to `Menu`, limiting its applicability to other hierarchical components. In contrast, `CheckBox` and `FlagSelector` show that local handling is adequate for most stateful views, where state changes are self-contained or communicated via view-specific events. `ListView` similarly operates locally, with `SelectedItemChanged` or similar events handling external notifications. `Button`’s focus-based `Selecting` is inherently local, requiring no propagation. This dichotomy suggests that while propagation is critical for certain hierarchical scenarios (e.g., menus), it’s unnecessary for many views, and any propagation mechanism must avoid coupling subviews to superviews to maintain encapsulation. +- **Context Insight**: The `MenuBar` implementation demonstrates a clear need for propagation to manage `PopoverMenu` visibility, as it must react to `MenuItemv2` selections (e.g., focus changes) across its submenu hierarchy. The reliance on `SelectedMenuItemChanged` works but is specific to `Menu`, limiting its applicability to other hierarchical components. In contrast, `CheckBox` and `FlagSelector` show that local handling is adequate for most stateful views, where state changes are self-contained or communicated via view-specific events. `ListView` similarly operates locally, with `SelectedItemChanged` or similar events handling external notifications. `Button`’s focus-based `Activating` is inherently local, requiring no propagation. This dichotomy suggests that while propagation is critical for certain hierarchical scenarios (e.g., menus), it’s unnecessary for many views, and any propagation mechanism must avoid coupling subviews to superviews to maintain encapsulation. -- **Verdict**: The local handling of `Command.Select` is sufficient for most views, including `CheckBox`, `FlagSelector`, `ListView`, and `Button`, where state changes or preparatory actions are internal or communicated via view-specific events. However, `MenuBar`’s requirement for hierarchical coordination to manage `PopoverMenu` visibility highlights a gap in the current design, where view-specific events like `SelectedMenuItemChanged` are used as a workaround. A generic propagation model would enhance flexibility for hierarchical components, but it must ensure that subviews (e.g., `MenuItemv2`) remain decoupled from superviews (e.g., `MenuBar`) to avoid implementation-specific dependencies. The current lack of propagation is a limitation, particularly for menus, but adding it requires careful design to avoid overcomplicating the API or impacting performance for views that don’t need it. +- **Verdict**: The local handling of `Command.Activate` is sufficient for most views, including `CheckBox`, `FlagSelector`, `ListView`, and `Button`, where state changes or preparatory actions are internal or communicated via view-specific events. However, `MenuBar`’s requirement for hierarchical coordination to manage `PopoverMenu` visibility highlights a gap in the current design, where view-specific events like `SelectedMenuItemChanged` are used as a workaround. A generic propagation model would enhance flexibility for hierarchical components, but it must ensure that subviews (e.g., `MenuItemv2`) remain decoupled from superviews (e.g., `MenuBar`) to avoid implementation-specific dependencies. The current lack of propagation is a limitation, particularly for menus, but adding it requires careful design to avoid overcomplicating the API or impacting performance for views that don’t need it. -**Recommendation**: Maintain the local handling of `Command.Select` for now, as it meets the needs of most views like `CheckBox`, `FlagSelector`, and `ListView`. For `MenuBar`, continue using `SelectedMenuItemChanged` as a temporary solution, but prioritize developing a generic propagation mechanism that supports hierarchical coordination without coupling subviews to superviews. This mechanism should allow superviews to opt-in to receiving `Selecting` events from subviews, ensuring encapsulation (see appendix for a proposed solution). +**Recommendation**: Maintain the local handling of `Command.Activate` for now, as it meets the needs of most views like `CheckBox`, `FlagSelector`, and `ListView`. For `MenuBar`, continue using `SelectedMenuItemChanged` as a temporary solution, but prioritize developing a generic propagation mechanism that supports hierarchical coordination without coupling subviews to superviews. This mechanism should allow superviews to opt-in to receiving `Activating` events from subviews, ensuring encapsulation (see appendix for a proposed solution). ## Recommendations for Refining the Design Based on the analysis of the current `Command` and `View.Command` system, as implemented in `Menu`, `MenuBar`, `CheckBox`, and `FlagSelector`, the following recommendations aim to refine the system’s clarity, consistency, and flexibility while addressing identified limitations: -1. **Clarify Selecting/Accepting in Documentation**: - - Explicitly define `Selecting` as state changes or interaction preparation (e.g., toggling a `CheckBox`, focusing a `MenuItemv2`, selecting a `ListView` item) and `Accepting` as action confirmations (e.g., executing a menu command, submitting a dialog). - - Emphasize that `Command.Select` may set focus in stateless views (e.g., `Button`, `MenuItemv2`) but is primarily intended for state changes, to reduce confusion for developers. +1. **Clarify Activating/Accepting in Documentation**: + - Explicitly define `Activating` as state changes or interaction preparation (e.g., toggling a `CheckBox`, focusing a `MenuItemv2`, selecting a `ListView` item) and `Accepting` as action confirmations (e.g., executing a menu command, submitting a dialog). + - Emphasize that `Command.Activate` may set focus in stateless views (e.g., `Button`, `MenuItemv2`) but is primarily intended for state changes, to reduce confusion for developers. - Provide examples for each view type (e.g., `Menu`, `CheckBox`, `FlagSelector`, `ListView`, `Button`) to illustrate their distinct roles. For instance: - - `Menu`: “`Selecting` focuses a `MenuItemv2` via arrow keys, while `Accepting` executes the selected command.” - - `CheckBox`: “`Selecting` toggles the `CheckedState`, while `Accepting` confirms the current state.” - - `FlagSelector`: “`Selecting` toggles a subview flag, while `Accepting` confirms the entire flag set.” + - `Menu`: “`Activating` focuses a `MenuItemv2` via arrow keys, while `Accepting` executes the selected command.” + - `CheckBox`: “`Activating` toggles the `CheckedState`, while `Accepting` confirms the current state.” + - `FlagSelector`: “`Activating` toggles a subview flag, while `Accepting` confirms the entire flag set.” - Document the `Cancel` property’s role in `CommandEventArgs`, noting its current limitation (implying negation rather than completion) and the planned replacement with `Handled` to align with input events like `Key.Handled`. 2. **Address FlagSelector Design Flaw**: - - Refactor `FlagSelector`’s `CheckBox.Selecting` handler to separate `Selecting` and `Accepting` actions, ensuring `Selecting` is limited to subview state changes (toggling flags) and `Accepting` is reserved for parent-level confirmation of the `Value`. This resolves the conflation issue where subview `Selecting` incorrectly triggers `Accepting`. + - Refactor `FlagSelector`’s `CheckBox.Activating` handler to separate `Activating` and `Accepting` actions, ensuring `Activating` is limited to subview state changes (toggling flags) and `Accepting` is reserved for parent-level confirmation of the `Value`. This resolves the conflation issue where subview `Activating` incorrectly triggers `Accepting`. - Proposed fix: ```csharp - checkbox.Selecting += (sender, args) => + checkbox.Activating += (sender, args) => { - if (RaiseSelecting(args.Context) is true) + if (RaiseActivating(args.Context) is true) { args.Cancel = true; } }; ``` - - This ensures `Selecting` only propagates state changes to the parent `FlagSelector` via `RaiseSelecting`, and `Accepting` is triggered separately (e.g., via Enter on the `FlagSelector` itself) to confirm the `Value`. + - This ensures `Activating` only propagates state changes to the parent `FlagSelector` via `RaiseActivating`, and `Accepting` is triggered separately (e.g., via Enter on the `FlagSelector` itself) to confirm the `Value`. 3. **Enhance ICommandContext with View-Specific State**: - Enrich `ICommandContext` with a `State` property to include view-specific data (e.g., the selected `MenuItemv2` in `Menu`, the new `CheckedState` in `CheckBox`, the updated `Value` in `FlagSelector`). This enables more informed event handlers without requiring view-specific subscriptions. @@ -588,34 +607,34 @@ Based on the analysis of the current `Command` and `View.Command` system, as imp object? State { get; } // View-specific state (e.g., selected item, CheckState) } ``` - - Example: In `Menu`, include the `SelectedMenuItem` in `ICommandContext.State` for `Selecting` handlers: + - Example: In `Menu`, include the `SelectedMenuItem` in `ICommandContext.State` for `Activating` handlers: ```csharp - protected bool? RaiseSelecting(ICommandContext? ctx) + protected bool? RaiseActivating(ICommandContext? ctx) { ctx.State = SelectedMenuItem; // Provide selected MenuItemv2 CommandEventArgs args = new() { Context = ctx }; - if (OnSelecting(args) || args.Cancel) + if (OnActivating(args) || args.Cancel) { return true; } - Selecting?.Invoke(this, args); - return Selecting is null ? null : args.Cancel; + Activating?.Invoke(this, args); + return Activating is null ? null : args.Cancel; } ``` - This enhances the flexibility of event handlers, allowing external code to react to state changes without subscribing to view-specific events like `SelectedMenuItemChanged` or `CheckedStateChanged`. 4. **Monitor Use Cases for Propagation Needs**: - - Track the usage of `Selecting` and `Accepting` in real-world applications, particularly in `Menu`, `MenuBar`, `CheckBox`, and `FlagSelector`, to identify scenarios where propagation of `Selecting` events could simplify hierarchical coordination. + - Track the usage of `Activating` and `Accepting` in real-world applications, particularly in `Menu`, `MenuBar`, `CheckBox`, and `FlagSelector`, to identify scenarios where propagation of `Activating` events could simplify hierarchical coordination. - Collect feedback on whether the reliance on view-specific events (e.g., `SelectedMenuItemChanged` in `Menu`) is sufficient or if a generic propagation model would reduce complexity for hierarchical components like `MenuBar`. This will inform the design of a propagation mechanism that maintains subview-superview decoupling (see appendix). - Example focus areas: - `MenuBar`: Assess whether `SelectedMenuItemChanged` adequately handles `PopoverMenu` visibility or if propagation would streamline the interaction model. - - `Dialog`: Evaluate whether `Selecting` propagation could enhance subview coordination (e.g., tracking checkbox toggles within a dialog). + - `Dialog`: Evaluate whether `Activating` propagation could enhance subview coordination (e.g., tracking checkbox toggles within a dialog). - `TabView`: Consider potential needs for tab selection coordination if implemented in the future. 5. **Improve Propagation for Hierarchical Views**: - - Recognize the limitation in `Command.Select`’s local handling for hierarchical components like `MenuBar`, where superviews need to react to subview selections (e.g., focusing a `MenuItemv2` to manage popovers). The current reliance on `SelectedMenuItemChanged` is effective but view-specific, limiting reusability. - - Develop a propagation mechanism that allows superviews to opt-in to receiving `Selecting` events from subviews without requiring subviews to know superview details, ensuring encapsulation. This could involve a new event or property in `View` to enable propagation while maintaining decoupling (see appendix for a proposed solution). - - Example: For `MenuBar`, a propagation mechanism could allow it to handle `Selecting` events from `MenuItemv2` subviews to show or hide popovers, replacing the need for `SelectedMenuItemChanged`: + - Recognize the limitation in `Command.Activate`’s local handling for hierarchical components like `MenuBar`, where superviews need to react to subview selections (e.g., focusing a `MenuItemv2` to manage popovers). The current reliance on `SelectedMenuItemChanged` is effective but view-specific, limiting reusability. + - Develop a propagation mechanism that allows superviews to opt-in to receiving `Activating` events from subviews without requiring subviews to know superview details, ensuring encapsulation. This could involve a new event or property in `View` to enable propagation while maintaining decoupling (see appendix for a proposed solution). + - Example: For `MenuBar`, a propagation mechanism could allow it to handle `Activating` events from `MenuItemv2` subviews to show or hide popovers, replacing the need for `SelectedMenuItemChanged`: ```csharp // Current workaround in MenuBar protected override void OnSelectedMenuItemChanged(MenuItemv2? selected) @@ -635,7 +654,7 @@ Based on the analysis of the current `Command` and `View.Command` system, as imp return SuperMenuItem?.InvokeCommand(Command.Accept, args.Context) is true; } ``` - - Explore a more generic mechanism, such as allowing superviews to subscribe to `Accepting` events from subviews, to streamline propagation and improve encapsulation. This could be addressed in conjunction with `Selecting` propagation (see appendix). + - Explore a more generic mechanism, such as allowing superviews to subscribe to `Accepting` events from subviews, to streamline propagation and improve encapsulation. This could be addressed in conjunction with `Activating` propagation (see appendix). - Example: In `Menu`, a subscription-based model could replace `SuperMenuItem` logic: ```csharp // Hypothetical subscription in Menu @@ -650,22 +669,24 @@ Based on the analysis of the current `Command` and `View.Command` system, as imp ## Conclusion -The `Command` and `View.Command` system in Terminal.Gui provides a robust framework for handling view actions, with `Selecting` and `Accepting` serving as opinionated mechanisms for state changes/preparation and action confirmations. The system is effectively implemented across `Menu`, `MenuBar`, `CheckBox`, and `FlagSelector`, supporting a range of stateful and stateless interactions. However, limitations in terminology (`Select`’s ambiguity), cancellation semantics (`Cancel`’s misleading implication), and propagation (local `Selecting` handling) highlight areas for improvement. +The `Command` and `View.Command` system in Terminal.Gui provides a robust framework for handling view actions, with `Activating` and `Accepting` serving as opinionated mechanisms for state changes/preparation and action confirmations. The system is effectively implemented across `Menu`, `MenuBar`, `CheckBox`, and `FlagSelector`, supporting a range of stateful and stateless interactions. However, limitations in terminology (`Select`’s ambiguity), cancellation semantics (`Cancel`’s misleading implication), and propagation (local `Activating` handling) highlight areas for improvement. -The `Selecting`/`Accepting` distinction is clear in principle but requires careful documentation to avoid confusion, particularly for stateless views where `Selecting` is focus-driven and for views like `FlagSelector` where implementation flaws conflate the two concepts. View-specific events like `SelectedMenuItemChanged`, `CheckedStateChanged`, and `ValueChanged` are sufficient for post-selection notifications, negating the need for a generic `Selected` event. The `Accepted` event is valuable in hierarchical views like `Menu` and `MenuBar` but not universally required, suggesting inclusion in `Bar` or `Runnable` rather than `View`. +The `Activating`/`Accepting` distinction is clear in principle but requires careful documentation to avoid confusion, particularly for stateless views where `Activating` is focus-driven and for views like `FlagSelector` where implementation flaws conflate the two concepts. View-specific events like `SelectedMenuItemChanged`, `CheckedStateChanged`, and `ValueChanged` are sufficient for post-selection notifications, negating the need for a generic `Selected` event. The `Accepted` event is valuable in hierarchical views like `Menu` and `MenuBar` but not universally required, suggesting inclusion in `Bar` or `Runnable` rather than `View`. By clarifying terminology, fixing implementation flaws (e.g., `FlagSelector`), enhancing `ICommandContext`, and developing a decoupled propagation model, Terminal.Gui can enhance the `Command` system’s clarity and flexibility, particularly for hierarchical components like `MenuBar`. The appendix summarizes proposed changes to address these limitations, aligning with a filed issue to guide future improvements. -## Appendix: Summary of Proposed Changes to Command System +## Appendix: Summary of Changes and Remaining Proposals to Command System -A filed issue proposes enhancements to the `Command` system to address limitations in terminology, cancellation semantics, and propagation, informed by `Menu`, `MenuBar`, `CheckBox`, and `FlagSelector`. These changes are not yet implemented but aim to improve clarity, consistency, and flexibility. +A filed issue proposed enhancements to the `Command` system to address limitations in terminology, cancellation semantics, and propagation, informed by `Menu`, `MenuBar`, `CheckBox`, and `FlagSelector`. The renaming from `Command.Select` to `Command.Activate` has been completed. Remaining proposed changes aim to improve clarity, consistency, and flexibility. -### Proposed Changes -1. **Rename `Command.Select` to `Command.Activate`**: - - Replace `Command.Select`, `Selecting` event, `OnSelecting`, and `RaiseSelecting` with `Command.Activate`, `Activating`, `OnActivating`, and `RaiseActivating`. - - Rationale: “Select” is ambiguous for stateless views (e.g., `Button` focus) and imprecise for non-list state changes (e.g., `CheckBox` toggling). “Activate” better captures state changes and preparation. +### Completed Changes +1. **Renamed `Command.Select` to `Command.Activate`** ✓: + - Replaced `Command.Select`, `Selecting` event, `OnSelecting`, and `RaiseSelecting` with `Command.Activate`, `Activating`, `OnActivating`, and `RaiseActivating`. + - Rationale: "Select" was ambiguous for stateless views (e.g., `Button` focus) and imprecise for non-list state changes (e.g., `CheckBox` toggling). "Activate" better captures state changes and preparation. - Impact: Breaking change requiring codebase updates and migration guidance. +### Remaining Proposed Changes + 2. **Replace `Cancel` with `Handled` in `CommandEventArgs`**: - Replace `Cancel` with `Handled` to indicate command completion, aligning with `Key.Handled` (issue #3913). - Rationale: `Cancel` implies negation, not completion. @@ -675,7 +696,6 @@ A filed issue proposes enhancements to the `Command` system to address limitatio - Add `event EventHandler? PropagateActivating` to `View`, allowing superviews (e.g., `MenuBar`) to subscribe to subview propagation requests. - Rationale: Enables hierarchical coordination (e.g., `MenuBar` managing `PopoverMenu` visibility) without coupling subviews to superviews, addressing the current reliance on view-specific events like `SelectedMenuItemChanged`. - Impact: Enhances flexibility for hierarchical views, requires subscription management in superviews like `MenuBar`. - ### Benefits - **Clarity**: `Activate` improves terminology for all views. - **Consistency**: `Handled` aligns with input events. diff --git a/docfx/docs/events.md b/docfx/docs/events.md index 88e7a457c..14e2aecf6 100644 --- a/docfx/docs/events.md +++ b/docfx/docs/events.md @@ -213,14 +213,14 @@ public class Aligner : INotifyPropertyChanged ### 4. Event Propagation -Events in Terminal.Gui often propagate through the view hierarchy. For example, in `Button`, the `Selecting` and `Accepting` events are raised as part of the command handling process: +Events in Terminal.Gui often propagate through the view hierarchy. For example, in `Button`, the `Activating` and `Accepting` events are raised as part of the command handling process: ```csharp private bool? HandleHotKeyCommand (ICommandContext commandContext) { bool cachedIsDefault = IsDefault; // Supports "Swap Default" in Buttons scenario where IsDefault changes - if (RaiseSelecting (commandContext) is true) + if (RaiseActivating (commandContext) is true) { return true; } @@ -244,7 +244,7 @@ private bool? HandleHotKeyCommand (ICommandContext commandContext) } ``` -This example shows how `Button` first raises the `Selecting` event, and if not canceled, proceeds to raise the `Accepting` event. If `Accepting` is not handled and the button is the default, it invokes the `Accept` command on the `SuperView`, demonstrating event propagation up the view hierarchy. +This example shows how `Button` first raises the `Activating` event, and if not canceled, proceeds to raise the `Accepting` event. If `Accepting` is not handled and the button is the default, it invokes the `Accept` command on the `SuperView`, demonstrating event propagation up the view hierarchy. ## Event Context diff --git a/docfx/docs/index.md b/docfx/docs/index.md index 437d34ffc..1f197e9ba 100644 --- a/docfx/docs/index.md +++ b/docfx/docs/index.md @@ -22,7 +22,7 @@ Welcome to the Terminal.Gui documentation! This comprehensive guide covers every - [Arrangement](~/docs/arrangement.md) - View arrangement and positioning strategies - [Cancellable Work Pattern](~/docs/cancellable-work-pattern.md) - Core design pattern for extensible workflows - [Character Map Scenario](~/docs/CharacterMap.md) - Complex drawing, scrolling, and Unicode rendering example -- [Command System](~/docs/command.md) - Command execution, key bindings, and the Selecting/Accepting concepts +- [Command System](~/docs/command.md) - Command execution, key bindings, and the Activating/Accepting concepts - [Configuration Management](~/docs/config.md) - Persistent settings, themes, and configuration scopes - [Cross-Platform Driver Model](~/docs/drivers.md) - Platform abstraction and console driver architecture - [Cursor System](~/docs/cursor.md) - Modern cursor management and positioning (proposed design) diff --git a/docfx/docs/migratingfromv1.md b/docfx/docs/migratingfromv1.md index e19ac5033..a00e62561 100644 --- a/docfx/docs/migratingfromv1.md +++ b/docfx/docs/migratingfromv1.md @@ -577,9 +577,9 @@ view.MouseClick += (mouseEvent) => **v2:** ```csharp -// v2 - Use MouseBindings + Commands + Selecting event -view.MouseBindings.Add(MouseFlags.Button1Clicked, Command.Select); -view.Selecting += (s, e) => +// v2 - Use MouseBindings + Commands + Activating event +view.MouseBindings.Add(MouseFlags.Button1Clicked, Command.Activate); +view.Activating += (s, e) => { // Handle selection (called when Button1Clicked) DoSomething(); @@ -599,8 +599,8 @@ view.MouseEvent += (s, e) => **Key Changes:** - `View.MouseClick` event has been **removed** - Use `MouseBindings` to map mouse events to `Command`s -- Default mouse bindings invoke `Command.Select` which raises the `Selecting` event -- For custom behavior, override `OnSelecting` or subscribe to the `Selecting` event +- Default mouse bindings invoke `Command.Activate` which raises the `Activating` event +- For custom behavior, override `OnActivating` or subscribe to the `Activating` event - For low-level mouse handling, use `MouseEvent` directly **Migration Pattern:** @@ -616,8 +616,8 @@ protected override bool OnMouseClick(MouseEventArgs mouseEvent) return base.OnMouseClick(mouseEvent); } -// ✅ v2 - OnSelecting override -protected override bool OnSelecting(CommandEventArgs args) +// ✅ v2 - OnActivating override +protected override bool OnActivating(CommandEventArgs args) { if (args.Context is CommandContext { Binding.MouseEventArgs: { } mouseArgs }) { @@ -628,20 +628,20 @@ protected override bool OnSelecting(CommandEventArgs args) return true; } } - return base.OnSelecting(args); + return base.OnActivating(args); } -// ✅ v2 - Selecting event (simpler) -view.Selecting += (s, e) => +// ✅ v2 - Activating event (simpler) +view.Activating += (s, e) => { PerformAction(); e.Handled = true; }; ``` -**Accessing Mouse Position in Selecting Event:** +**Accessing Mouse Position in Activating Event:** ```csharp -view.Selecting += (s, e) => +view.Activating += (s, e) => { // Extract mouse event args from command context if (e.Context is CommandContext { Binding.MouseEventArgs: { } mouseArgs }) diff --git a/docfx/docs/mouse.md b/docfx/docs/mouse.md index 494f2a13b..38d263123 100644 --- a/docfx/docs/mouse.md +++ b/docfx/docs/mouse.md @@ -44,9 +44,9 @@ public class MyView : View AddCommand (Command.ScrollDown, () => ScrollVertical (1)); MouseBindings.Add (MouseFlags.WheelDown, Command.ScrollDown); - // Mouse clicks invoke Command.Select by default + // Mouse clicks invoke Command.Activate by default // Override to customize click behavior - AddCommand (Command.Select, () => { + AddCommand (Command.Activate, () => { SelectItem(); return true; }); @@ -60,7 +60,7 @@ The @Terminal.Gui.Input.Command enum lists generic operations that are implement Here are some common mouse binding patterns used throughout Terminal.Gui: -* **Click Events**: `MouseFlags.Button1Clicked` for primary selection/activation - maps to `Command.Select` by default +* **Click Events**: `MouseFlags.Button1Clicked` for primary selection/activation - maps to `Command.Activate` by default * **Double-Click Events**: `MouseFlags.Button1DoubleClicked` for default actions (like opening/accepting) * **Right-Click Events**: `MouseFlags.Button3Clicked` for context menus * **Scroll Events**: `MouseFlags.WheelUp` and `MouseFlags.WheelDown` for scrolling content @@ -71,22 +71,22 @@ Here are some common mouse binding patterns used throughout Terminal.Gui: By default, all views have the following mouse bindings configured: ```cs -MouseBindings.Add (MouseFlags.Button1Clicked, Command.Select); -MouseBindings.Add (MouseFlags.Button2Clicked, Command.Select); -MouseBindings.Add (MouseFlags.Button3Clicked, Command.Select); -MouseBindings.Add (MouseFlags.Button4Clicked, Command.Select); -MouseBindings.Add (MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl, Command.Select); +MouseBindings.Add (MouseFlags.Button1Clicked, Command.Activate); +MouseBindings.Add (MouseFlags.Button2Clicked, Command.Activate); +MouseBindings.Add (MouseFlags.Button3Clicked, Command.Activate); +MouseBindings.Add (MouseFlags.Button4Clicked, Command.Activate); +MouseBindings.Add (MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl, Command.Activate); ``` -When a mouse click occurs, the `Command.Select` is invoked, which raises the `Selecting` event. Views can override `OnSelecting` or subscribe to the `Selecting` event to handle clicks: +When a mouse click occurs, the `Command.Activate` is invoked, which raises the `Activating` event. Views can override `OnActivating` or subscribe to the `Activating` event to handle clicks: ```cs public class MyView : View { public MyView() { - // Option 1: Subscribe to Selecting event - Selecting += (s, e) => + // Option 1: Subscribe to Activating event + Activating += (s, e) => { if (e.Context is CommandContext { Binding.MouseEventArgs: { } mouseArgs }) { @@ -97,8 +97,8 @@ public class MyView : View }; } - // Option 2: Override OnSelecting - protected override bool OnSelecting(CommandEventArgs args) + // Option 2: Override OnActivating + protected override bool OnActivating(CommandEventArgs args) { if (args.Context is CommandContext { Binding.MouseEventArgs: { } mouseArgs }) { @@ -109,7 +109,7 @@ public class MyView : View return true; } } - return base.OnSelecting(args); + return base.OnActivating(args); } } ``` @@ -173,17 +173,17 @@ public class CustomView : View ### Handling Mouse Clicks -The recommended pattern for handling mouse clicks is to use the `Selecting` event or override `OnSelecting`. This integrates with the command system and provides access to mouse event details through the command context: +The recommended pattern for handling mouse clicks is to use the `Activating` event or override `OnActivating`. This integrates with the command system and provides access to mouse event details through the command context: ```cs public class ClickableView : View { public ClickableView() { - Selecting += OnSelecting; + Activating += OnActivating; } - private void OnSelecting(object sender, CommandEventArgs e) + private void OnActivating(object sender, CommandEventArgs e) { // Extract mouse event information from command context if (e.Context is CommandContext { Binding.MouseEventArgs: { } mouseArgs }) @@ -218,7 +218,7 @@ public class MultiButtonView : View MouseBindings.Clear(); // Map different buttons to different commands - MouseBindings.Add(MouseFlags.Button1Clicked, Command.Select); + MouseBindings.Add(MouseFlags.Button1Clicked, Command.Activate); MouseBindings.Add(MouseFlags.Button3Clicked, Command.ContextMenu); AddCommand(Command.ContextMenu, HandleContextMenu); diff --git a/docfx/docs/navigation.md b/docfx/docs/navigation.md index 941f99017..893d3a414 100644 --- a/docfx/docs/navigation.md +++ b/docfx/docs/navigation.md @@ -442,7 +442,7 @@ view.HasFocusChanged += (sender, e) => The following table summarizes how built-in views respond to various input methods: -| View | States | Static | Default | HotKeys | Select Cmd | Accept Cmd | HotKey Cmd | Click Focus | DblClick | RightClick | GrabMouse | +| View | States | Static | Default | HotKeys | Activate Cmd | Accept Cmd | HotKey Cmd | Click Focus | DblClick | RightClick | GrabMouse | |------|--------|--------|---------|---------|------------|------------|------------|-------------|----------|------------|-----------| | **View** | 1 | Yes | No | 1 | OnSelect | OnAccept | Focus | Focus | - | - | No | | **Label** | 1 | Yes | No | 1 | OnSelect | OnAccept | FocusNext | Focus | - | FocusNext | No | @@ -460,7 +460,7 @@ The following table summarizes how built-in views respond to various input metho - **Static**: Whether the view is primarily for display (non-interactive) - **Default**: Whether the view can be a default button (activated by Enter) - **HotKeys**: Number of hotkeys the view typically supports -- **Select Cmd**: What happens when Command.Select is invoked +- **Activate Cmd**: What happens when Command.Activate is invoked - **Accept Cmd**: What happens when Command.Accept is invoked - **HotKey Cmd**: What happens when the view's hotkey is pressed - **Click Focus**: Behavior when clicked (if CanFocus=true) @@ -560,7 +560,7 @@ foreach (var view in container.Subviews) // Provide keyboard alternatives to mouse actions view.KeyBindings.Add(Key.F10, Command.Context); // Right-click equivalent -view.KeyBindings.Add(Key.Space, Command.Select); // Click equivalent +view.KeyBindings.Add(Key.Space, Command.Activate); // Click equivalent ``` For more information on accessibility standards, see: