From e834dfcd1cddf92d6da97ece355f5c9c808760c1 Mon Sep 17 00:00:00 2001 From: Tig Date: Sun, 30 Jun 2024 12:57:29 -0700 Subject: [PATCH] Removed HighlightEventArgs --- Terminal.Gui/View/Adornment/Border.cs | 2 +- Terminal.Gui/View/Adornment/Margin.cs | 2 +- Terminal.Gui/View/HighlightEventArgs.cs | 10 ---------- Terminal.Gui/View/ViewMouse.cs | 6 +++--- Terminal.Gui/Views/Shortcut.cs | 2 +- UnitTests/View/MouseTests.cs | 4 ++-- 6 files changed, 8 insertions(+), 18 deletions(-) delete mode 100644 Terminal.Gui/View/HighlightEventArgs.cs diff --git a/Terminal.Gui/View/Adornment/Border.cs b/Terminal.Gui/View/Adornment/Border.cs index 554eb5ea8..39d98f635 100644 --- a/Terminal.Gui/View/Adornment/Border.cs +++ b/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 e) { if (!Parent.Arrangement.HasFlag (ViewArrangement.Movable)) { diff --git a/Terminal.Gui/View/Adornment/Margin.cs b/Terminal.Gui/View/Adornment/Margin.cs index 502dafc17..11ae2dd2b 100644 --- a/Terminal.Gui/View/Adornment/Margin.cs +++ b/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 e) { if (ShadowStyle != Gui.ShadowStyle.None) { diff --git a/Terminal.Gui/View/HighlightEventArgs.cs b/Terminal.Gui/View/HighlightEventArgs.cs deleted file mode 100644 index d4f300485..000000000 --- a/Terminal.Gui/View/HighlightEventArgs.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Terminal.Gui; - -/// -/// Event arguments for the event. -/// -public class HighlightEventArgs : CancelEventArgs -{ - /// - public HighlightEventArgs (ref HighlightStyle currentValue, ref HighlightStyle newValue) : base (ref currentValue, ref newValue) { } -} diff --git a/Terminal.Gui/View/ViewMouse.cs b/Terminal.Gui/View/ViewMouse.cs index fc05744c1..24314f583 100644 --- a/Terminal.Gui/View/ViewMouse.cs +++ b/Terminal.Gui/View/ViewMouse.cs @@ -11,7 +11,7 @@ public partial class View /// Fired when the view is highlighted. Set to /// to implement a custom highlight scheme or prevent the view from being highlighted. /// - public event EventHandler Highlight; + public event EventHandler> Highlight; /// /// Gets or sets whether the 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. /// /// , if the event was handled, otherwise. - protected virtual bool? OnHighlight (HighlightEventArgs args) + protected virtual bool? OnHighlight (CancelEventArgs 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 (ref copy, ref newHighlightStyle); if (OnHighlight (args) == true) { diff --git a/Terminal.Gui/Views/Shortcut.cs b/Terminal.Gui/Views/Shortcut.cs index fd528506d..802631d52 100644 --- a/Terminal.Gui/Views/Shortcut.cs +++ b/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 e) { if (e.CurrentValue.HasFlag (HighlightStyle.Pressed)) { diff --git a/UnitTests/View/MouseTests.cs b/UnitTests/View/MouseTests.cs index 760e3a416..956f4b202 100644 --- a/UnitTests/View/MouseTests.cs +++ b/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 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 e) { if (e.NewValue == HighlightStyle.None) {