mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
MouseEventArgs cleanup
This commit is contained in:
@@ -255,17 +255,17 @@ public static partial class Application // Mouse handling
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a mouse event occurs. Can be cancelled by setting <see cref="Terminal.Gui.MouseEventArgs.Handled"/> to <see langword="true"/>.
|
||||
/// Raised when a mouse event occurs. Can be cancelled by setting <see cref="MouseEventArgs.Handled"/> to <see langword="true"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// <see cref="Terminal.Gui.MouseEventArgs.ScreenPosition"/> coordinates are screen-relative.
|
||||
/// <see cref="MouseEventArgs.ScreenPosition"/> coordinates are screen-relative.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <see cref="Terminal.Gui.MouseEventArgs.View"/> will be the deepest view under the under the mouse.
|
||||
/// <see cref="MouseEventArgs.View"/> will be the deepest view under the under the mouse.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <see cref="Terminal.Gui.MouseEventArgs.Position"/> coordinates are view-relative.
|
||||
/// <see cref="MouseEventArgs.Position"/> coordinates are view-relative. Only valid if <see cref="MouseEventArgs.View"/> is set.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Use this evento to handle mouse events at the application level, before View-specific handling.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
#nullable enable
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Terminal.Gui;
|
||||
|
||||
@@ -20,12 +21,12 @@ public class MouseEventArgs : HandledEventArgs
|
||||
public Point ScreenPosition { get; set; }
|
||||
|
||||
/// <summary>The deepest View who's <see cref="View.Frame"/> contains <see cref="ScreenPosition"/>.</summary>
|
||||
public View View { get; set; }
|
||||
public View? View { get; set; }
|
||||
|
||||
/// <summary>The position of the mouse in <see cref="View"/>'s Viewport-relative coordinates. Only valid if <see cref="View"/> is set.</summary>
|
||||
public Point Position { get; set; }
|
||||
|
||||
/// <summary>Returns a <see cref="T:System.String"/> that represents the current <see cref="Terminal.Gui.MouseEventArgs"/>.</summary>
|
||||
/// <returns>A <see cref="T:System.String"/> that represents the current <see cref="Terminal.Gui.MouseEventArgs"/>.</returns>
|
||||
public override string ToString () { return $"({ScreenPosition}):{Flags}:{View.Id}:{Position}"; }
|
||||
public override string ToString () { return $"({ScreenPosition}):{Flags}:{View?.Id}:{Position}"; }
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class TabMouseEventArgs : EventArgs
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actual mouse event. Use <see cref="Terminal.Gui.MouseEventArgs.Handled"/> to cancel this event and perform custom
|
||||
/// Gets the actual mouse event. Use <see cref="MouseEventArgs.Handled"/> to cancel this event and perform custom
|
||||
/// behavior (e.g. show a context menu).
|
||||
/// </summary>
|
||||
public MouseEventArgs MouseEvent { get; }
|
||||
|
||||
@@ -196,7 +196,7 @@ In v1, the `Command` enum had duplicate entries and inconsistent naming. In v2 i
|
||||
|
||||
The API for mouse input is now internally consistent and easier to use.
|
||||
|
||||
* The @Terminal.Gui.MouseEvent class replaces `MouseEventEventArgs`.
|
||||
* The @Terminal.Gui.MouseEventArgs class replaces `MouseEventEventArgs`.
|
||||
* More granular APIs are provided to ease handling specific mouse actions. See [Mouse API](mouse.md).
|
||||
* Views can use the @Terminal.Gui.View.Highlight event to have the view be visibly highlighted on various mouse events.
|
||||
* Views can set `View.WantContinousButtonPresses = true` to have their @Terminal.Gui.Command.Accept command be invoked repeatedly as the user holds a mouse button down on the view.
|
||||
@@ -213,7 +213,7 @@ The API for mouse input is now internally consistent and easier to use.
|
||||
|
||||
```diff
|
||||
- Application.RootMouseEvent(KeyEvent arg)
|
||||
+ Application.MouseEvent(object? sender, MouseEvent mouseEvent)
|
||||
+ Application.MouseEvent(object? sender, MouseEventArgs mouseEvent)
|
||||
```
|
||||
|
||||
## Navigation - `Cursor`, `Focus`, `TabStop` etc...
|
||||
|
||||
Reference in New Issue
Block a user