Przeglądaj źródła

Better class defn

Tig 1 rok temu
rodzic
commit
f3c3246f0d

+ 11 - 6
Terminal.Gui/View/CancelEventArgs.cs

@@ -4,17 +4,22 @@ using System.ComponentModel;
 namespace Terminal.Gui;
 
 /// <summary>
-/// <see cref="EventArgs"/> for events that convey changes to a property of type `T`.</summary>
+///     <see cref="EventArgs"/> for events that convey changes to a property of type <typeparamref name="T"/>.
+/// </summary>
+/// <typeparam name="T">The type of the value that was part of the change being canceled.</typeparam>
 /// <remarks>
-/// Events that use this class can be cancellable. Where applicable, the <see cref="CancelEventArgs.Cancel"/> property should be set to
-/// <see langword="true"/> to prevent the state change from occurring.
+///     Events that use this class can be cancellable. Where applicable, the <see cref="CancelEventArgs.Cancel"/> property
+///     should be set to
+///     <see langword="true"/> to prevent the state change from occurring.
 /// </remarks>
-public class CancelEventArgs<T> : CancelEventArgs
+public class CancelEventArgs<T> : CancelEventArgs where T : notnull
 {
     /// <summary>Initializes a new instance of the <see cref="CancelEventArgs{T}"/> class.</summary>
     /// <param name="currentValue">The current (old) value of the property.</param>
     /// <param name="newValue">The value the property will be set to if the event is not cancelled.</param>
-    public CancelEventArgs (T currentValue, T newValue)
+    /// <param name="cancel">Whether the event should be canceled or not.</param>
+    /// <typeparam name="T">The type of the value for the change being canceled.</typeparam>
+    public CancelEventArgs (T currentValue, T newValue, bool cancel = false) : base (cancel)
     {
         CurrentValue = currentValue;
         NewValue = newValue;
@@ -25,4 +30,4 @@ public class CancelEventArgs<T> : CancelEventArgs
 
     /// <summary>The current value of the property.</summary>
     public T CurrentValue { get; }
-}
+}

+ 2 - 1
Terminal.Gui/View/ViewEventArgs.cs

@@ -58,7 +58,8 @@ public class DrawEventArgs : EventArgs
 public class FocusEventArgs : EventArgs
 {
     /// <summary>Constructs.</summary>
-    /// <param name="leaving">The view that gets or loses focus.</param>
+    /// <param name="leaving">The view that is losing focus.</param>
+    /// <param name="entering">The view that is gaining focus.</param>
     public FocusEventArgs (View leaving, View entering) {
         Leaving = leaving;
         Entering = entering;