From f7d18ff876792084eeb99aa68ff24a8e31507d54 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 20 Jun 2024 16:36:01 -0700 Subject: [PATCH] Fixed docs --- Terminal.Gui/Views/Dialog.cs | 4 ++-- UICatalog/Scenarios/KeyBindings.cs | 12 +++++++----- UICatalog/Scenarios/MenuBarScenario.cs | 6 ++---- UICatalog/Scenarios/SingleBackgroundWorker.cs | 2 +- docfx/docs/migratingfromv1.md | 2 ++ docfx/docs/newinv2.md | 1 + 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index 2ab97a98e..b3e3730f9 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -10,8 +10,8 @@ namespace Terminal.Gui; /// /// To run the modally, create the , and pass it to /// . This will execute the dialog until -/// it terminates via the -/// [ESC] or [CTRL-Q] key, or when one of the views or buttons added to the dialog calls +/// it terminates via the (`Esc` by default), +/// or when one of the views or buttons added to the dialog calls /// . /// public class Dialog : Window diff --git a/UICatalog/Scenarios/KeyBindings.cs b/UICatalog/Scenarios/KeyBindings.cs index 3daa8c3c9..98350d564 100644 --- a/UICatalog/Scenarios/KeyBindings.cs +++ b/UICatalog/Scenarios/KeyBindings.cs @@ -54,11 +54,13 @@ public sealed class KeyBindings : Scenario Height = Dim.Auto (DimAutoStyle.Text), HotKeySpecifier = (Rune)'_', Title = "_KeyBindingsDemo", - Text = @"These keys will cause this view to show a message box: -- Hotkey: k, K, Alt-K, Alt-Shift-K -- Focused: F3 -- Application: F4 -Pressing Ctrl-Q will cause it to quit the app.", + Text = $""" + These keys will cause this view to show a message box: + - Hotkey: k, K, Alt-K, Alt-Shift-K + - Focused: F3 + - Application: F4 + Pressing Esc or {Application.QuitKey} will cause it to quit the app. + """, BorderStyle = LineStyle.Dashed }; appWindow.Add (keyBindingsDemo); diff --git a/UICatalog/Scenarios/MenuBarScenario.cs b/UICatalog/Scenarios/MenuBarScenario.cs index bef318f68..4dce938b4 100644 --- a/UICatalog/Scenarios/MenuBarScenario.cs +++ b/UICatalog/Scenarios/MenuBarScenario.cs @@ -57,16 +57,14 @@ public class MenuBarScenario : Scenario ), null, - // Don't use Ctrl-Q so we can disambiguate between quitting and closing the toplevel + // Don't use Application.Quit so we can disambiguate between quitting and closing the toplevel new ( "_Quit", "", () => actionFn ("Quit"), null, null, - KeyCode.AltMask - | KeyCode.CtrlMask - | KeyCode.Q + KeyCode.CtrlMask | KeyCode.Q ) } ), diff --git a/UICatalog/Scenarios/SingleBackgroundWorker.cs b/UICatalog/Scenarios/SingleBackgroundWorker.cs index 896cac096..3e990779f 100644 --- a/UICatalog/Scenarios/SingleBackgroundWorker.cs +++ b/UICatalog/Scenarios/SingleBackgroundWorker.cs @@ -203,7 +203,7 @@ public class SingleBackgroundWorker : Scenario _top.KeyDown += (s, e) => { - // Prevents Ctrl+Q from closing this. + // Prevents App.QuitKey from closing this. // Only Ctrl+C is allowed. if (e == Application.QuitKey) { diff --git a/docfx/docs/migratingfromv1.md b/docfx/docs/migratingfromv1.md index 4d6c09267..9c833cbfb 100644 --- a/docfx/docs/migratingfromv1.md +++ b/docfx/docs/migratingfromv1.md @@ -166,6 +166,7 @@ The API for handling keyboard input is significantly improved. See [Keyboard API * The [Key](~/api/Terminal.Gui.Key.yml) class replaces the `KeyEvent` struct and provides a platform-independent abstraction for common keyboard operations. It is used for processing keyboard input and raising keyboard events. This class provides a high-level abstraction with helper methods and properties for common keyboard operations. Use this class instead of the low-level [KeyCode](~/api/Terminal.Gui.KeyCode.yml) enum when possible. See [Key](~/api/Terminal.Gui.Key.yml) for more details. * The preferred way to enable Application-wide or View-heirarchy-dependent keystrokes is to use the [Shortcut](~/api/Terminal.Gui.Shortcut.yml) View or the built-in View's that utilize it, such as the [Bar](~/api/Terminal.Gui.Bar.yml)-based views. * The preferred way to handle single keystrokes is to use **Key Bindings**. Key Bindings map a key press to a [Command](~/api/Terminal.Gui.Command.yml). A view can declare which commands it supports, and provide a lambda that implements the functionality of the command, using `View.AddCommand()`. Use the [View.Keybindings](~/api/Terminal.Gui.View.Keybindings.yml) to configure the key bindings. +* For better consistency and user experience, the default key for closing an app or `Toplevel` is now `Esc` (it was previously `Ctrl+Q`). ### How to Fix @@ -173,6 +174,7 @@ The API for handling keyboard input is significantly improved. See [Keyboard API * Use [View.AddCommand](~/api/Terminal.Gui.View.AddCommand.yml) to define commands your view supports. * Use [View.Keybindings](~/api/Terminal.Gui.View.Keybindings.yml) to configure key bindings to `Command`s. * It should be very uncommon for v2 code to override `OnKeyPressed` etc... +* Anywhere `Ctrl+Q` was hard-coded as the "quit key", replace with `Application.QuitKey`. ## Updated Mouse API diff --git a/docfx/docs/newinv2.md b/docfx/docs/newinv2.md index 3d234aad2..96f68c888 100644 --- a/docfx/docs/newinv2.md +++ b/docfx/docs/newinv2.md @@ -55,6 +55,7 @@ The API for handling keyboard input is significantly improved. See [Keyboard API * The `Key` class replaces the `KeyEvent` struct and provides a platform-independent abstraction for common keyboard operations. It is used for processing keyboard input and raising keyboard events. This class provides a high-level abstraction with helper methods and properties for common keyboard operations. Use this class instead of the low-level `KeyCode` enum when possible. See [Key](~/api/Terminal.Gui.Key.yml) for more details. * The preferred way to handle single keystrokes is to use **Key Bindings**. Key Bindings map a key press to a [Command](~/api/Terminal.Gui.Command.yml). A view can declare which commands it supports, and provide a lambda that implements the functionality of the command, using `View.AddCommand()`. Use the `View.Keybindings` to configure the key bindings. +* For better consistency and user experience, the default key for closing an app or `Toplevel` is now `Esc` (it was previously `Ctrl+Q`). ## Updated Mouse API