Browse Source

Removed HighlightEventArgs

Tig 1 year ago
parent
commit
e834dfcd1c

+ 1 - 1
Terminal.Gui/View/Adornment/Border.cs

@@ -220,7 +220,7 @@ public class Border : Adornment
 
     private Color? _savedForeColor;
 
-    private void Border_Highlight (object sender, HighlightEventArgs e)
+    private void Border_Highlight (object sender, CancelEventArgs<HighlightStyle> e)
     {
         if (!Parent.Arrangement.HasFlag (ViewArrangement.Movable))
         {

+ 1 - 1
Terminal.Gui/View/Adornment/Margin.cs

@@ -39,7 +39,7 @@ public class Margin : Adornment
     }
 
     private bool _pressed;
-    private void Margin_Highlight (object? sender, HighlightEventArgs e)
+    private void Margin_Highlight (object? sender, CancelEventArgs<HighlightStyle> e)
     {
         if (ShadowStyle != Gui.ShadowStyle.None)
         {

+ 0 - 10
Terminal.Gui/View/HighlightEventArgs.cs

@@ -1,10 +0,0 @@
-namespace Terminal.Gui;
-
-/// <summary>
-/// Event arguments for the <see cref="View.Highlight"/> event.
-/// </summary>
-public class HighlightEventArgs : CancelEventArgs<HighlightStyle>
-{
-    /// <inheritdoc />
-    public HighlightEventArgs (ref HighlightStyle currentValue, ref HighlightStyle newValue) : base (ref currentValue, ref newValue) { }
-}

+ 3 - 3
Terminal.Gui/View/ViewMouse.cs

@@ -11,7 +11,7 @@ public partial class View
     ///     Fired when the view is highlighted. Set <see cref="CancelEventArgs.Cancel"/> to <see langword="true"/>
     ///     to implement a custom highlight scheme or prevent the view from being highlighted.
     /// </summary>
-    public event EventHandler<HighlightEventArgs> Highlight;
+    public event EventHandler<CancelEventArgs<HighlightStyle>> Highlight;
 
     /// <summary>
     ///     Gets or sets whether the <see cref="View"/> will be highlighted visually while the mouse button is
@@ -211,7 +211,7 @@ public partial class View
     ///     Called when the view is to be highlighted.
     /// </summary>
     /// <returns><see langword="true"/>, if the event was handled, <see langword="false"/> otherwise.</returns>
-    protected virtual bool? OnHighlight (HighlightEventArgs args)
+    protected virtual bool? OnHighlight (CancelEventArgs<HighlightStyle> args)
     {
         Highlight?.Invoke (this, args);
 
@@ -442,7 +442,7 @@ public partial class View
 
         // Enable override via virtual method and/or event
         HighlightStyle copy = HighlightStyle;
-        var args = new HighlightEventArgs (ref copy, ref newHighlightStyle);
+        var args = new CancelEventArgs<HighlightStyle> (ref copy, ref newHighlightStyle);
 
         if (OnHighlight (args) == true)
         {

+ 1 - 1
Terminal.Gui/Views/Shortcut.cs

@@ -295,7 +295,7 @@ public class Shortcut : View
 
     private Color? _savedForeColor;
 
-    private void Shortcut_Highlight (object sender, HighlightEventArgs e)
+    private void Shortcut_Highlight (object sender, CancelEventArgs<HighlightStyle> e)
     {
         if (e.CurrentValue.HasFlag (HighlightStyle.Pressed))
         {

+ 2 - 2
UnitTests/View/MouseTests.cs

@@ -566,7 +566,7 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews
 
         return;
 
-        void View_Highlight (object sender, HighlightEventArgs e)
+        void View_Highlight (object sender, CancelEventArgs<HighlightStyle> e)
         {
             if (e.NewValue == HighlightStyle.None)
             {
@@ -635,7 +635,7 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews
 
         return;
 
-        void View_Highlight (object sender, HighlightEventArgs e)
+        void View_Highlight (object sender, CancelEventArgs<HighlightStyle> e)
         {
             if (e.NewValue == HighlightStyle.None)
             {