diff --git a/Terminal.Gui/Configuration/ThemeScope.cs b/Terminal.Gui/Configuration/ThemeScope.cs index 22da7e4f2..35b568b32 100644 --- a/Terminal.Gui/Configuration/ThemeScope.cs +++ b/Terminal.Gui/Configuration/ThemeScope.cs @@ -176,14 +176,14 @@ namespace Terminal.Gui.Configuration { internal void OnThemeChanged (string theme) { Debug.WriteLine ($"Themes.OnThemeChanged({theme}) -> {Theme}"); - ThemeChanged?.Invoke (new ThemeManagerEventArgs (theme)); + ThemeChanged?.Invoke (this, new ThemeManagerEventArgs (theme)); } /// /// Event fired he selected theme has changed. /// application. /// - public event Action? ThemeChanged; + public event EventHandler? ThemeChanged; /// /// Holds the definitions. diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs index 83be1867c..e21be4471 100644 --- a/Terminal.Gui/Core/Application.cs +++ b/Terminal.Gui/Core/Application.cs @@ -267,7 +267,7 @@ namespace Terminal.Gui { /// must also subscribe to /// and manually dispose of the token when the application is done. /// - public static event Action NotifyStopRunState; + public static event EventHandler NotifyStopRunState; /// /// This event is raised on each iteration of the . @@ -723,12 +723,12 @@ namespace Terminal.Gui { /// /// Event to be invoked when a view grab the mouse. /// - public static event Action GrabbedMouse; + public static event EventHandler GrabbedMouse; /// /// Event to be invoked when a view ungrab the mouse. /// - public static event Action UnGrabbedMouse; + public static event EventHandler UnGrabbedMouse; /// /// Grabs the mouse, forcing all mouse events to be routed to the specified view until UngrabMouse is called. @@ -760,14 +760,14 @@ namespace Terminal.Gui { { if (view == null) return; - GrabbedMouse?.Invoke (view); + GrabbedMouse?.Invoke (view, new ViewEventArgs(view)); } static void OnUnGrabbedMouse (View view) { if (view == null) return; - UnGrabbedMouse?.Invoke (view); + UnGrabbedMouse?.Invoke (view, new ViewEventArgs (view)); } /// @@ -1497,7 +1497,7 @@ namespace Terminal.Gui { static void OnNotifyStopRunState (Toplevel top) { if (ExitRunLoopAfterFirstIteration) { - NotifyStopRunState?.Invoke (top); + NotifyStopRunState?.Invoke (top, new ToplevelEventArgs(top)); } } diff --git a/Terminal.Gui/Core/EventArgs/ViewEventArgs.cs b/Terminal.Gui/Core/EventArgs/ViewEventArgs.cs new file mode 100644 index 000000000..4dbafcc1a --- /dev/null +++ b/Terminal.Gui/Core/EventArgs/ViewEventArgs.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Terminal.Gui{ + public class ViewEventArgs :EventArgs{ + public ViewEventArgs (View view) + { + View = view; + } + + public View View { get; } + } +} diff --git a/UnitTests/Application/ApplicationTests.cs b/UnitTests/Application/ApplicationTests.cs index 222057f72..dda308372 100644 --- a/UnitTests/Application/ApplicationTests.cs +++ b/UnitTests/Application/ApplicationTests.cs @@ -978,27 +978,27 @@ namespace Terminal.Gui.ApplicationTests { Assert.Equal (grabView, view2); Assert.Null (Application.MouseGrabView); - void Application_GrabbedMouse (View obj) + void Application_GrabbedMouse (object sender, ViewEventArgs e) { if (count == 0) { - Assert.Equal (view1, obj); + Assert.Equal (view1, e.View); grabView = view1; } else { - Assert.Equal (view2, obj); + Assert.Equal (view2, e.View); grabView = view2; } Application.GrabbedMouse -= Application_GrabbedMouse; } - void Application_UnGrabbedMouse (View obj) + void Application_UnGrabbedMouse (object sender, ViewEventArgs e) { if (count == 0) { - Assert.Equal (view1, obj); - Assert.Equal (grabView, obj); + Assert.Equal (view1, e.View); + Assert.Equal (grabView, e.View); } else { - Assert.Equal (view2, obj); - Assert.Equal (grabView, obj); + Assert.Equal (view2, e.View); + Assert.Equal (grabView, e.View); } count++;