diff --git a/Terminal.Gui/Text/StringEventArgs.cs b/Terminal.Gui/Text/StringEventArgs.cs
deleted file mode 100644
index 734f828b2..000000000
--- a/Terminal.Gui/Text/StringEventArgs.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System.ComponentModel;
-
-namespace Terminal.Gui;
-
-/// Cancellable event args for string-based property change events.
-public class StringEventArgs : CancelEventArgs
-{
- ///
- /// Initializes a new instance of
- ///
- public StringEventArgs () {}
-
- /// Initializes a new instance of
- /// The old string.
- /// The new string.
- public StringEventArgs (string oldString, string newString)
- {
- OldValue = oldString;
- NewValue = newString;
- }
- /// The new string.
- public string NewValue { get; set; }
-
- /// The old string.
- public string OldValue { get; set; }
-}
diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs
index 0e36a80c2..b71dd5a02 100644
--- a/Terminal.Gui/Views/TextValidateField.cs
+++ b/Terminal.Gui/Views/TextValidateField.cs
@@ -64,8 +64,8 @@ namespace Terminal.Gui
/// Method that invoke the event if it's defined.
/// The previous text before replaced.
- /// Returns the
- void OnTextChanged (StringEventArgs oldValue);
+ /// Returns the
+ void OnTextChanged (CancelEventArgs oldValue);
///
/// Changed event, raised when the text has changed.
@@ -74,7 +74,7 @@ namespace Terminal.Gui
/// containing the old value.
///
///
- event EventHandler TextChanged;
+ event EventHandler> TextChanged;
}
//////////////////////////////////////////////////////////////////////////////
@@ -125,7 +125,7 @@ namespace Terminal.Gui
}
///
- public event EventHandler TextChanged;
+ public event EventHandler> TextChanged;
///
public string Text
@@ -206,7 +206,7 @@ namespace Terminal.Gui
if (result)
{
- OnTextChanged (new StringEventArgs { NewValue = oldValue });
+ OnTextChanged (new CancelEventArgs (oldValue, Text));
}
return result;
@@ -220,14 +220,14 @@ namespace Terminal.Gui
if (result)
{
- OnTextChanged (new StringEventArgs { NewValue = oldValue });
+ OnTextChanged (new CancelEventArgs (oldValue, Text));
}
return result;
}
///
- public void OnTextChanged (StringEventArgs oldValue) { TextChanged?.Invoke (this, oldValue); }
+ public void OnTextChanged (CancelEventArgs args) { TextChanged?.Invoke (this, args); }
}
#endregion
@@ -260,7 +260,7 @@ namespace Terminal.Gui
public bool ValidateOnInput { get; set; } = true;
///
- public event EventHandler TextChanged;
+ public event EventHandler> TextChanged;
///
public string Text
@@ -333,7 +333,7 @@ namespace Terminal.Gui
{
string oldValue = Text;
_text.RemoveAt (pos);
- OnTextChanged (new StringEventArgs { NewValue = Text, OldValue = oldValue });
+ OnTextChanged (new CancelEventArgs (oldValue, Text));
}
return true;
@@ -349,7 +349,7 @@ namespace Terminal.Gui
{
string oldValue = Text;
_text.Insert (pos, (Rune)ch);
- OnTextChanged (new StringEventArgs { NewValue = Text, OldValue = oldValue });
+ OnTextChanged (new CancelEventArgs (oldValue, Text));
return true;
}
@@ -358,7 +358,7 @@ namespace Terminal.Gui
}
///
- public void OnTextChanged (StringEventArgs oldValue) { TextChanged?.Invoke (this, oldValue); }
+ public void OnTextChanged (CancelEventArgs args) { TextChanged?.Invoke (this, args); }
/// Compiles the regex pattern for validation./>
private void CompileMask () { _regex = new Regex (StringExtensions.ToString (_pattern), RegexOptions.Compiled); }
diff --git a/Terminal.Gui/Views/Tile.cs b/Terminal.Gui/Views/Tile.cs
index df7cefbb7..f495f42fa 100644
--- a/Terminal.Gui/Views/Tile.cs
+++ b/Terminal.Gui/Views/Tile.cs
@@ -61,7 +61,7 @@ public class Tile
/// The new to be replaced.
public virtual void OnTitleChanged (string oldTitle, string newTitle)
{
- var args = new StringEventArgs (oldTitle, newTitle);
+ var args = new CancelEventArgs (oldTitle, newTitle);
TitleChanged?.Invoke (this, args);
}
@@ -74,18 +74,18 @@ public class Tile
/// true if an event handler cancelled the Title change.
public virtual bool OnTitleChanging (string oldTitle, string newTitle)
{
- var args = new StringEventArgs (oldTitle, newTitle);
+ var args = new CancelEventArgs (oldTitle, newTitle);
TitleChanging?.Invoke (this, args);
return args.Cancel;
}
/// Event fired after the has been changed.
- public event EventHandler TitleChanged;
+ public event EventHandler> TitleChanged;
///
/// Event fired when the is changing.
/// can be set to true to cancel the change.
///
- public event EventHandler TitleChanging;
+ public event EventHandler> TitleChanging;
}