Fixed docs

This commit is contained in:
Tig
2024-06-20 16:36:01 -07:00
parent 639357a7f3
commit f7d18ff876
6 changed files with 15 additions and 12 deletions

View File

@@ -10,8 +10,8 @@ namespace Terminal.Gui;
/// <remarks>
/// To run the <see cref="Dialog"/> modally, create the <see cref="Dialog"/>, and pass it to
/// <see cref="Application.Run(Toplevel, Func{Exception, bool})"/>. 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 <see cref="Application.QuitKey"/> (`Esc` by default),
/// or when one of the views or buttons added to the dialog calls
/// <see cref="Application.RequestStop"/>.
/// </remarks>
public class Dialog : Window

View File

@@ -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);

View File

@@ -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
)
}
),

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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