diff --git a/Terminal.Gui/Core/FocusEventArgs.cs b/Terminal.Gui/Core/FocusEventArgs.cs deleted file mode 100644 index e019d5a0a..000000000 --- a/Terminal.Gui/Core/FocusEventArgs.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace Terminal.Gui { - - /// - /// Defines the event arguments for - /// - public class FocusEventArgs : EventArgs { - /// - /// Constructs. - /// - /// The view that gets or loses focus. - public FocusEventArgs (View view) { View = view; } - /// - /// Indicates if the current focus event has already been processed and the driver should stop notifying any other event subscriber. - /// Its important to set this value to true specially when updating any View's layout from inside the subscriber method. - /// - public bool Handled { get; set; } - /// - /// Indicates the current view that gets or loses focus. - /// - public View View { get; set; } - } - -} diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index 1c1372b47..7dc074a9b 100644 --- a/Terminal.Gui/Core/View.cs +++ b/Terminal.Gui/Core/View.cs @@ -139,17 +139,17 @@ namespace Terminal.Gui { /// /// Event fired when the view receives the mouse event for the first time. /// - public event EventHandler MouseEnter; + public event EventHandler MouseEnter; /// /// Event fired when the view receives a mouse event for the last time. /// - public event EventHandler MouseLeave; + public event EventHandler MouseLeave; /// /// Event fired when a mouse event is generated. /// - public event EventHandler MouseClick; + public event EventHandler MouseClick; /// /// Event fired when the value is being changed. @@ -827,7 +827,7 @@ namespace Terminal.Gui { void TextFormatter_HotKeyChanged (object sender, KeyChangedEventArgs e) { - HotKeyChanged?.Invoke (this,e); + HotKeyChanged?.Invoke (this, e); } /// @@ -942,7 +942,7 @@ namespace Terminal.Gui { } SetNeedsLayout (); SetNeedsDisplay (); - OnAdded (new SuperViewChangedEventArgs (this,view)); + OnAdded (new SuperViewChangedEventArgs (this, view)); if (IsInitialized) { view.BeginInit (); view.EndInit (); @@ -1344,7 +1344,7 @@ namespace Terminal.Gui { view.width ??= view.frame.Width; view.height ??= view.frame.Height; - view.Added?.Invoke (this,e); + view.Added?.Invoke (this, e); } /// @@ -1593,7 +1593,7 @@ namespace Terminal.Gui { /// public virtual void OnDrawContent (Rect viewport) { - DrawContent?.Invoke (this, new DrawEventArgs(viewport)); + DrawContent?.Invoke (this, new DrawEventArgs (viewport)); } /// @@ -2239,16 +2239,6 @@ namespace Terminal.Gui { } } - /// - /// Event arguments for the event. - /// - public class LayoutEventArgs : EventArgs { - /// - /// The view-relative bounds of the before it was laid out. - /// - public Rect OldBounds { get; set; } - } - /// /// Fired after the View's method has completed. /// @@ -2795,34 +2785,6 @@ namespace Terminal.Gui { frame.Size.Height + GetHotKeySpecifierLength (false)); } - /// - /// Specifies the event arguments for . This is a higher-level construct - /// than the wrapped class and is used for the events defined on - /// and subclasses of View (e.g. and ). - /// - public class MouseEventArgs : EventArgs { - /// - /// Constructs. - /// - /// - public MouseEventArgs (MouseEvent me) => MouseEvent = me; - /// - /// The for the event. - /// - public MouseEvent MouseEvent { get; set; } - - /// - /// Indicates if the current mouse event has already been processed and the driver should stop notifying any other event subscriber. - /// Its important to set this value to true specially when updating any View's layout from inside the subscriber method. - /// - /// This property forwards to the property and is provided as a convenience and for - /// backwards compatibility - public bool Handled { - get => MouseEvent.Handled; - set => MouseEvent.Handled = value; - } - } - /// public override bool OnMouseEnter (MouseEvent mouseEvent) { @@ -2834,7 +2796,7 @@ namespace Terminal.Gui { return false; } - var args = new MouseEventArgs (mouseEvent); + var args = new MouseEventEventArgs (mouseEvent); MouseEnter?.Invoke (this, args); return args.Handled || base.OnMouseEnter (mouseEvent); @@ -2851,7 +2813,7 @@ namespace Terminal.Gui { return false; } - var args = new MouseEventArgs (mouseEvent); + var args = new MouseEventEventArgs (mouseEvent); MouseLeave?.Invoke (this, args); return args.Handled || base.OnMouseLeave (mouseEvent); @@ -2872,7 +2834,7 @@ namespace Terminal.Gui { return false; } - var args = new MouseEventArgs (mouseEvent); + var args = new MouseEventEventArgs (mouseEvent); if (OnMouseClick (args)) return true; if (MouseEvent (mouseEvent)) @@ -2892,7 +2854,7 @@ namespace Terminal.Gui { /// /// Invokes the MouseClick event. /// - protected bool OnMouseClick (MouseEventArgs args) + protected bool OnMouseClick (MouseEventEventArgs args) { if (!Enabled) { return true; diff --git a/Terminal.Gui/Core/ViewEventArgs.cs b/Terminal.Gui/Core/ViewEventArgs.cs index 53b1a985b..277ddbc67 100644 --- a/Terminal.Gui/Core/ViewEventArgs.cs +++ b/Terminal.Gui/Core/ViewEventArgs.cs @@ -1,17 +1,13 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Terminal.Gui { /// /// Args for events that relate to specific /// - public class ViewEventArgs :EventArgs{ + public class ViewEventArgs : EventArgs { /// - /// Creates a new instance of the class. + /// Creates a new instance of the class. /// /// public ViewEventArgs (View view) @@ -30,4 +26,55 @@ namespace Terminal.Gui { /// public View View { get; } } + + /// + /// Event arguments for the event. + /// + public class LayoutEventArgs : EventArgs { + /// + /// The view-relative bounds of the before it was laid out. + /// + public Rect OldBounds { get; set; } + } + + /// + /// Event args for draw events + /// + public class DrawEventArgs : EventArgs { + + /// + /// Creates a new instance of the class. + /// + /// Gets the view-relative rectangle describing the currently visible viewport into the . + public DrawEventArgs (Rect rect) + { + Rect = rect; + } + + /// + /// Gets the view-relative rectangle describing the currently visible viewport into the . + /// + public Rect Rect { get; } + } + + /// + /// Defines the event arguments for + /// + public class FocusEventArgs : EventArgs { + /// + /// Constructs. + /// + /// The view that gets or loses focus. + public FocusEventArgs (View view) { View = view; } + /// + /// Indicates if the current focus event has already been processed and the driver should stop notifying any other event subscriber. + /// Its important to set this value to true specially when updating any View's layout from inside the subscriber method. + /// + public bool Handled { get; set; } + /// + /// Indicates the current view that gets or loses focus. + /// + public View View { get; set; } + } + } diff --git a/Terminal.Gui/Views/DrawEventArgs.cs b/Terminal.Gui/Views/DrawEventArgs.cs deleted file mode 100644 index 65aee2438..000000000 --- a/Terminal.Gui/Views/DrawEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Terminal.Gui { - - /// - /// Event args for draw events - /// - public class DrawEventArgs : EventArgs{ - - /// - /// Creates a new instance of the class. - /// - /// Gets the view-relative rectangle describing the currently visible viewport into the . - public DrawEventArgs (Rect rect) - { - Rect = rect; - } - - /// - /// Gets the view-relative rectangle describing the currently visible viewport into the . - /// - public Rect Rect { get; } - } -}