mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Doc updates.
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
|
||||
* *Parent View* - A view that holds a reference to another view in a parent/child relationship, but is NOT a SuperView of the child. Terminal.Gui uses the terms "Child" and "Parent" sparingly. Generally Subview/SuperView is preferred.
|
||||
|
||||
### Input
|
||||
|
||||
See the [Keyboard Deep Dive](keyboard.md) and [Mouse Deep Dive](mouse.md).
|
||||
|
||||
### Layout and Arrangement
|
||||
|
||||
See the [Layout Deep Dive](layout.md) and the [Arrangement Deep Dive](arrangement.md).
|
||||
|
||||
@@ -66,13 +66,13 @@ Use @Terminal.Gui.Application.KeyBindings to add or modify Application-scoped Ke
|
||||
|
||||
**Application-Scoped** Key Bindings
|
||||
|
||||
### **@"Terminal.Gui.View.HotKey"**
|
||||
### HotKey
|
||||
|
||||
A **HotKey** is a key press that selects a visible UI item. For selecting items across `View`s (e.g. a `Button` in a `Dialog`) the key press must have the `Alt` modifier. For selecting items within a `View` that are not `View`s themselves, the key press can be key without the `Alt` modifier. For example, in a `Dialog`, a `Button` with the text of "_Text" can be selected with `Alt+T`. Or, in a `Menu` with "_File _Edit", `Alt+F` will select (show) the "_File" menu. If the "_File" menu has a sub-menu of "_New" `Alt+N` or `N` will ONLY select the "_New" sub-menu if the "_File" menu is already opened.
|
||||
|
||||
By default, the `Text` of a `View` is used to determine the `HotKey` by looking for the first occurrence of the @Terminal.Gui.View.HotKeySpecifier (which is underscore (`_`) by default). The character following the underscore is the `HotKey`. If the `HotKeySpecifier` is not found in `Text`, the first character of `Text` is used as the `HotKey`. The `Text` of a `View` can be changed at runtime, and the `HotKey` will be updated accordingly. @"Terminal.Gui.View.HotKey" is `virtual` enabling this behavior to be customized.
|
||||
|
||||
### **[Shortcut](~/api/Terminal.Gui.Shortcut.yml)**
|
||||
### **Shortcut**
|
||||
|
||||
A **Shortcut** is an opinionated (visually & API) View for displaying a command, help text, key key press that invokes a [Command](~/api/Terminal.Gui.Command.yml).
|
||||
|
||||
@@ -141,7 +141,7 @@ To define application key handling logic for an entire application in cases wher
|
||||
|
||||
## View
|
||||
|
||||
* Implements support for `KeyBindingScope.View` and `KeyBindingScope.HotKey`.
|
||||
* Implements support for `KeyBindings` and `HotKeyBindings`.
|
||||
* Exposes cancelable non-virtual methods for a new key event: `NewKeyDownEvent` and `NewKeyUpEvent`. These methods are called by `Application` can be called to simulate keyboard input.
|
||||
* Exposes cancelable virtual methods for a new key event: `OnKeyDown` and `OnKeyUp`. These methods are called by `NewKeyDownEvent` and `NewKeyUpEvent` and can be overridden to handle keyboard input.
|
||||
|
||||
|
||||
@@ -10,6 +10,30 @@ Tenets higher in the list have precedence over tenets lower in the list.
|
||||
|
||||
## Mouse APIs
|
||||
|
||||
*Terminal.Gui* provides the following APIs for handling mouse input:
|
||||
|
||||
* **MouseEventArgs** - @Terminal.Gui.MouseEventArgs provides a platform-independent abstraction for common mouse operations. It is used for processing mouse input and raising mouse events.
|
||||
* **Mouse Bindings** - Mouse Bindings provide a declarative method for handling mouse input in View implementations. The View calls @Terminal.Gui.AddCommand to declare it supports a particular command and then uses @Terminal.Gui.MouseBindings to indicate which mouse events will invoke the command.
|
||||
* **Mouse Events** - The Mouse Bindings API is rich enough to support the majority of use-cases. However, in some cases subscribing directly to key events is needed (e.g. drag & drop). Use @Terminal.Gui.View.MouseEvent and related events in these cases.
|
||||
|
||||
Each of these APIs are described more fully below.
|
||||
|
||||
## Mouse Bindings
|
||||
|
||||
Mouse Bindings is the preferred way of handling mouse input in View implementations. The View calls @Terminal.Gui.AddCommand to declare it supports a particular command and then uses @Terminal.Gui.MouseBindings to indicate which mouse events will invoke the command. For example, if a View wants to respond to the user using the mouse wheel to scroll up, it would do this:
|
||||
|
||||
```cs
|
||||
public MyView : View
|
||||
{
|
||||
AddCommand (Command.ScrollUp, () => ScrollVertical (-1));
|
||||
MouseBindings.Add (MouseFlags.Button1DoubleClick, Command.ScrollUp);
|
||||
}
|
||||
```
|
||||
|
||||
The [Command](~/api/Terminal.Gui.Command.yml) enum lists generic operations that are implemented by views.
|
||||
|
||||
## Mouse Events
|
||||
|
||||
At the core of *Terminal.Gui*'s mouse API is the @Terminal.Gui.MouseEventArgs class. The @Terminal.Gui.MouseEventArgs class provides a platform-independent abstraction for common mouse events. Every mouse event can be fully described in a @Terminal.Gui.MouseEventArgs instance, and most of the mouse-related APIs are simply helper functions for decoding a @Terminal.Gui.MouseEventArgs.
|
||||
|
||||
When the user does something with the mouse, the `ConsoleDriver` maps the platform-specific mouse event into a `MouseEventArgs` and calls `Application.RaiseMouseEvent`. Then, `Application.RaiseMouseEvent` determines which `View` the event should go to. The `View.OnMouseEvent` method can be overridden or the `View.MouseEvent` event can be subscribed to, to handle the low-level mouse event. If the low-level event is not handled by a view, `Application` will then call the appropriate high-level helper APIs. For example, if the user double-clicks the mouse, `View.OnMouseClick` will be called/`View.MouseClick` will be raised with the event arguments indicating which mouse button was double-clicked.
|
||||
|
||||
Reference in New Issue
Block a user