Bläddra i källkod

Convert more Actions to EventHandlers in View

tznind 2 år sedan
förälder
incheckning
43f67a6387
35 ändrade filer med 85 tillägg och 85 borttagningar
  1. 16 16
      Terminal.Gui/Core/View.cs
  2. 1 1
      Terminal.Gui/Views/ComboBox.cs
  3. 1 1
      Terminal.Gui/Windows/Dialog.cs
  4. 1 1
      Terminal.Gui/Windows/FileDialog.cs
  5. 1 1
      UICatalog/KeyBindingsDialog.cs
  6. 1 1
      UICatalog/Scenarios/ASCIICustomButton.cs
  7. 1 1
      UICatalog/Scenarios/AllViewsTester.cs
  8. 1 1
      UICatalog/Scenarios/AutoSizeAndDirectionText.cs
  9. 2 2
      UICatalog/Scenarios/BackgroundWorkerCollection.cs
  10. 1 1
      UICatalog/Scenarios/CharacterMap.cs
  11. 1 1
      UICatalog/Scenarios/ComputedLayout.cs
  12. 1 1
      UICatalog/Scenarios/ContextMenus.cs
  13. 1 1
      UICatalog/Scenarios/CsvEditor.cs
  14. 2 2
      UICatalog/Scenarios/DynamicMenuBar.cs
  15. 2 2
      UICatalog/Scenarios/DynamicStatusBar.cs
  16. 1 1
      UICatalog/Scenarios/Editor.cs
  17. 1 1
      UICatalog/Scenarios/InteractiveTree.cs
  18. 4 4
      UICatalog/Scenarios/Keys.cs
  19. 1 1
      UICatalog/Scenarios/Notepad.cs
  20. 2 2
      UICatalog/Scenarios/SendKeys.cs
  21. 1 1
      UICatalog/Scenarios/SingleBackgroundWorker.cs
  22. 1 1
      UICatalog/Scenarios/TableEditor.cs
  23. 1 1
      UICatalog/Scenarios/TextAlignmentsAndDirection.cs
  24. 1 1
      UICatalog/Scenarios/TextViewAutocompletePopup.cs
  25. 1 1
      UICatalog/Scenarios/TreeViewFileSystem.cs
  26. 6 6
      UICatalog/Scenarios/VkeyPacketSimulator.cs
  27. 1 1
      UICatalog/UICatalog.cs
  28. 1 1
      UnitTests/Application/ApplicationTests.cs
  29. 17 17
      UnitTests/Core/ViewTests.cs
  30. 3 3
      UnitTests/Drivers/ConsoleDriverTests.cs
  31. 1 1
      UnitTests/Menus/ContextMenuTests.cs
  32. 1 1
      UnitTests/TopLevels/ToplevelTests.cs
  33. 4 4
      UnitTests/Types/DimTests.cs
  34. 2 2
      UnitTests/Types/PosTests.cs
  35. 2 2
      UnitTests/UICatalog/ScenarioTests.cs

+ 16 - 16
Terminal.Gui/Core/View.cs

@@ -1713,7 +1713,7 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// Invoked when a character key is pressed and occurs after the key up event.
 		/// </summary>
-		public event Action<KeyEventEventArgs> KeyPress;
+		public event EventHandler<KeyEventEventArgs> KeyPress;
 
 		/// <inheritdoc/>
 		public override bool ProcessKey (KeyEvent keyEvent)
@@ -1723,11 +1723,11 @@ namespace Terminal.Gui {
 			}
 
 			var args = new KeyEventEventArgs (keyEvent);
-			KeyPress?.Invoke (args);
+			KeyPress?.Invoke (this, args);
 			if (args.Handled)
 				return true;
 			if (Focused?.Enabled == true) {
-				Focused?.KeyPress?.Invoke (args);
+				Focused?.KeyPress?.Invoke (this, args);
 				if (args.Handled)
 					return true;
 			}
@@ -1899,7 +1899,7 @@ namespace Terminal.Gui {
 
 			var args = new KeyEventEventArgs (keyEvent);
 			if (MostFocused?.Enabled == true) {
-				MostFocused?.KeyPress?.Invoke (args);
+				MostFocused?.KeyPress?.Invoke (this, args);
 				if (args.Handled)
 					return true;
 			}
@@ -1922,11 +1922,11 @@ namespace Terminal.Gui {
 			}
 
 			var args = new KeyEventEventArgs (keyEvent);
-			KeyPress?.Invoke (args);
+			KeyPress?.Invoke (this, args);
 			if (args.Handled)
 				return true;
 			if (MostFocused?.Enabled == true) {
-				MostFocused?.KeyPress?.Invoke (args);
+				MostFocused?.KeyPress?.Invoke (this, args);
 				if (args.Handled)
 					return true;
 			}
@@ -1944,7 +1944,7 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// Invoked when a key is pressed.
 		/// </summary>
-		public event Action<KeyEventEventArgs> KeyDown;
+		public event EventHandler<KeyEventEventArgs> KeyDown;
 
 		/// <inheritdoc/>
 		public override bool OnKeyDown (KeyEvent keyEvent)
@@ -1954,12 +1954,12 @@ namespace Terminal.Gui {
 			}
 
 			var args = new KeyEventEventArgs (keyEvent);
-			KeyDown?.Invoke (args);
+			KeyDown?.Invoke (this, args);
 			if (args.Handled) {
 				return true;
 			}
 			if (Focused?.Enabled == true) {
-				Focused.KeyDown?.Invoke (args);
+				Focused.KeyDown?.Invoke (this, args);
 				if (args.Handled) {
 					return true;
 				}
@@ -1974,7 +1974,7 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// Invoked when a key is released.
 		/// </summary>
-		public event Action<KeyEventEventArgs> KeyUp;
+		public event EventHandler<KeyEventEventArgs> KeyUp;
 
 		/// <inheritdoc/>
 		public override bool OnKeyUp (KeyEvent keyEvent)
@@ -1984,12 +1984,12 @@ namespace Terminal.Gui {
 			}
 
 			var args = new KeyEventEventArgs (keyEvent);
-			KeyUp?.Invoke (args);
+			KeyUp?.Invoke (this, args);
 			if (args.Handled) {
 				return true;
 			}
 			if (Focused?.Enabled == true) {
-				Focused.KeyUp?.Invoke (args);
+				Focused.KeyUp?.Invoke (this, args);
 				if (args.Handled) {
 					return true;
 				}
@@ -2295,14 +2295,14 @@ namespace Terminal.Gui {
 		/// <remarks>
 		/// Subscribe to this event to perform tasks when the <see cref="View"/> has been resized or the layout has otherwise changed.
 		/// </remarks>
-		public event Action<LayoutEventArgs> LayoutStarted;
+		public event EventHandler<LayoutEventArgs> LayoutStarted;
 
 		/// <summary>
 		/// Raises the <see cref="LayoutStarted"/> event. Called from  <see cref="LayoutSubviews"/> before any subviews have been laid out.
 		/// </summary>
 		internal virtual void OnLayoutStarted (LayoutEventArgs args)
 		{
-			LayoutStarted?.Invoke (args);
+			LayoutStarted?.Invoke (this, args);
 		}
 
 		/// <summary>
@@ -2311,7 +2311,7 @@ namespace Terminal.Gui {
 		/// <remarks>
 		/// Subscribe to this event to perform tasks when the <see cref="View"/> has been resized or the layout has otherwise changed.
 		/// </remarks>
-		public event Action<LayoutEventArgs> LayoutComplete;
+		public event EventHandler<LayoutEventArgs> LayoutComplete;
 
 		/// <summary>
 		/// Event called only once when the <see cref="View"/> is being initialized for the first time.
@@ -2325,7 +2325,7 @@ namespace Terminal.Gui {
 		/// </summary>
 		internal virtual void OnLayoutComplete (LayoutEventArgs args)
 		{
-			LayoutComplete?.Invoke (args);
+			LayoutComplete?.Invoke (this, args);
 		}
 
 		internal void CollectPos (Pos pos, View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)

+ 1 - 1
Terminal.Gui/Views/ComboBox.cs

@@ -299,7 +299,7 @@ namespace Terminal.Gui {
 			this.Add (search, listview);
 
 			// On resize
-			LayoutComplete += (LayoutEventArgs a) => {
+			LayoutComplete += (object sender, LayoutEventArgs a) => {
 				if ((!autoHide && Bounds.Width > 0 && search.Frame.Width != Bounds.Width) ||
 					(autoHide && Bounds.Width > 0 && search.Frame.Width != Bounds.Width - 1)) {
 					search.Width = listview.Width = autoHide ? Bounds.Width - 1 : Bounds.Width;

+ 1 - 1
Terminal.Gui/Windows/Dialog.cs

@@ -88,7 +88,7 @@ namespace Terminal.Gui {
 				}
 			}
 
-			LayoutStarted += (args) => {
+			LayoutStarted += (s, args) => {
 				LayoutStartedHandler ();
 			};
 		}

+ 1 - 1
Terminal.Gui/Windows/FileDialog.cs

@@ -745,7 +745,7 @@ namespace Terminal.Gui {
 			// On success, we will set this to false.
 			canceled = true;
 
-			KeyPress += (e) => {
+			KeyPress += (s, e) => {
 				if (e.KeyEvent.Key == Key.Esc) {
 					Cancel ();
 					e.Handled = true;

+ 1 - 1
UICatalog/KeyBindingsDialog.cs

@@ -179,7 +179,7 @@ namespace UICatalog {
 
 			// prompt user to hit a key
 			var dlg = new Dialog ("Enter Key");
-			dlg.KeyPress += (k) => {
+			dlg.KeyPress += (s, k) => {
 				key = k.KeyEvent.Key;
 				Application.RequestStop ();
 			};

+ 1 - 1
UICatalog/Scenarios/ASCIICustomButton.cs

@@ -230,7 +230,7 @@ namespace UICatalog.Scenarios {
 				}
 			}
 
-			private void Button_KeyPress (KeyEventEventArgs obj)
+			private void Button_KeyPress (object sender, KeyEventEventArgs obj)
 			{
 				switch (obj.KeyEvent.Key) {
 				case Key.End:

+ 1 - 1
UICatalog/Scenarios/AllViewsTester.cs

@@ -424,7 +424,7 @@ namespace UICatalog.Scenarios {
 			return view;
 		}
 
-		void LayoutCompleteHandler (View.LayoutEventArgs args)
+		void LayoutCompleteHandler (object sender, View.LayoutEventArgs args)
 		{
 			UpdateTitle (_curView);
 		}

+ 1 - 1
UICatalog/Scenarios/AutoSizeAndDirectionText.cs

@@ -90,7 +90,7 @@ namespace UICatalog.Scenarios {
 			};
 			Win.Add (ckbWideText);
 
-			Win.KeyUp += (_) =>
+			Win.KeyUp += (s,e) =>
 				labelH.Text = labelV.Text = text = editText.Text.ToString ();
 		}
 	}

+ 2 - 2
UICatalog/Scenarios/BackgroundWorkerCollection.cs

@@ -338,13 +338,13 @@ namespace UICatalog.Scenarios {
 				close.Clicked += OnReportClosed;
 				Add (close);
 
-				KeyPress += (e) => {
+				KeyPress += (s, e) => {
 					if (e.KeyEvent.Key == Key.Esc) {
 						OnReportClosed ();
 					}
 				};
 
-				LayoutStarted += (_) => {
+				LayoutStarted += (s,e) => {
 					var btnsWidth = start.Bounds.Width + close.Bounds.Width + 2 - 1;
 					var shiftLeft = Math.Max ((Bounds.Width - btnsWidth) / 2 - 2, 0);
 

+ 1 - 1
UICatalog/Scenarios/CharacterMap.cs

@@ -157,7 +157,7 @@ namespace UICatalog.Scenarios {
 			ContentSize = new Size (CharMap.RowWidth, (int)(MaxCodePointVal / 16 + 1));
 			ShowVerticalScrollIndicator = true;
 			ShowHorizontalScrollIndicator = false;
-			LayoutComplete += (args) => {
+			LayoutComplete += (s, args) => {
 				if (Bounds.Width < RowWidth) {
 					ShowHorizontalScrollIndicator = true;
 				} else {

+ 1 - 1
UICatalog/Scenarios/ComputedLayout.cs

@@ -49,7 +49,7 @@ namespace UICatalog.Scenarios {
 				ColorScheme = Colors.Error
 			};
 
-			Application.Top.LayoutComplete += (a) => {
+			Application.Top.LayoutComplete += (s, a) => {
 				horizontalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)];
 				verticalRuler.Text = vrule.Repeat ((int)Math.Ceiling ((double)(verticalRuler.Bounds.Height * 2) / (double)rule.Length)) [0..(verticalRuler.Bounds.Height*2)];
 			};

+ 1 - 1
UICatalog/Scenarios/ContextMenus.cs

@@ -58,7 +58,7 @@ namespace UICatalog.Scenarios {
 
 			Point mousePos = default;
 
-			Win.KeyPress += (e) => {
+			Win.KeyPress += (s, e) => {
 				if (e.KeyEvent.Key == (Key.Space | Key.CtrlMask)) {
 					ShowContextMenu (mousePos.X, mousePos.Y);
 					e.Handled = true;

+ 1 - 1
UICatalog/Scenarios/CsvEditor.cs

@@ -472,7 +472,7 @@ namespace UICatalog.Scenarios {
 
 		}
 
-		private void TableViewKeyPress (View.KeyEventEventArgs e)
+		private void TableViewKeyPress (object sender, View.KeyEventEventArgs e)
 		{
 			if (e.KeyEvent.Key == Key.DeleteChar) {
 

+ 2 - 2
UICatalog/Scenarios/DynamicMenuBar.cs

@@ -729,7 +729,7 @@ namespace UICatalog.Scenarios {
 					Width = Dim.Fill (),
 					ReadOnly = true
 				};
-				_txtShortcut.KeyDown += (e) => {
+				_txtShortcut.KeyDown += (s, e) => {
 					if (!ProcessKey (e.KeyEvent)) {
 						return;
 					}
@@ -772,7 +772,7 @@ namespace UICatalog.Scenarios {
 					return true;
 				}
 
-				_txtShortcut.KeyUp += (e) => {
+				_txtShortcut.KeyUp += (s, e) => {
 					var k = ShortcutHelper.GetModifiersKey (e.KeyEvent);
 					if (CheckShortcut (k, false)) {
 						e.Handled = true;

+ 2 - 2
UICatalog/Scenarios/DynamicStatusBar.cs

@@ -401,7 +401,7 @@ namespace UICatalog.Scenarios {
 					Width = Dim.Fill (),
 					ReadOnly = true
 				};
-				_txtShortcut.KeyDown += (e) => {
+				_txtShortcut.KeyDown += (s, e) => {
 					if (!ProcessKey (e.KeyEvent)) {
 						return;
 					}
@@ -445,7 +445,7 @@ namespace UICatalog.Scenarios {
 					return true;
 				}
 
-				_txtShortcut.KeyUp += (e) => {
+				_txtShortcut.KeyUp += (s, e) => {
 					var k = ShortcutHelper.GetModifiersKey (e.KeyEvent);
 					if (CheckShortcut (k, false)) {
 						e.Handled = true;

+ 1 - 1
UICatalog/Scenarios/Editor.cs

@@ -171,7 +171,7 @@ namespace UICatalog.Scenarios {
 				_scrollBar.Refresh ();
 			};
 
-			Win.KeyPress += (e) => {
+			Win.KeyPress += (s, e) => {
 				var keys = ShortcutHelper.GetModifiersKey (e.KeyEvent);
 				if (_winDialog != null && (e.KeyEvent.Key == Key.Esc
 					|| e.KeyEvent.Key == (Key.Q | Key.CtrlMask))) {

+ 1 - 1
UICatalog/Scenarios/InteractiveTree.cs

@@ -49,7 +49,7 @@ namespace UICatalog.Scenarios {
 
 		}
 
-		private void TreeView_KeyPress (View.KeyEventEventArgs obj)
+		private void TreeView_KeyPress (object sender, View.KeyEventEventArgs obj)
 		{
 			if (obj.KeyEvent.Key == Key.DeleteChar) {
 

+ 4 - 4
UICatalog/Scenarios/Keys.cs

@@ -92,7 +92,7 @@ namespace UICatalog.Scenarios {
 			};
 			Win.Add (labelKeypress);
 
-			Win.KeyPress += (a) => labelKeypress.Text = a.KeyEvent.ToString ();
+			Win.KeyPress += (s,e) => labelKeypress.Text = e.KeyEvent.ToString ();
 
 			// Key stroke log:
 			var keyLogLabel = new Label ("Key stroke log:") {
@@ -169,9 +169,9 @@ namespace UICatalog.Scenarios {
 				Height = Dim.Fill (),
 			};
 
-			Win.KeyDown += (a) => KeyDownPressUp (a.KeyEvent, "Down");
-			Win.KeyPress += (a) => KeyDownPressUp (a.KeyEvent, "Press");
-			Win.KeyUp += (a) => KeyDownPressUp (a.KeyEvent, "Up");
+			Win.KeyDown += (s,a) => KeyDownPressUp (a.KeyEvent, "Down");
+			Win.KeyPress += (s, a) => KeyDownPressUp (a.KeyEvent, "Press");
+			Win.KeyUp += (s, a) => KeyDownPressUp (a.KeyEvent, "Up");
 
 			void KeyDownPressUp (KeyEvent keyEvent, string updown)
 			{

+ 1 - 1
UICatalog/Scenarios/Notepad.cs

@@ -352,7 +352,7 @@ namespace UICatalog.Scenarios {
 			{
 				var textView = (TextView)View;
 				// when user makes changes rename tab to indicate unsaved
-				textView.KeyUp += (k) => {
+				textView.KeyUp += (s, k) => {
 
 					// if current text doesn't match saved text
 					var areDiff = this.UnsavedChanges;

+ 2 - 2
UICatalog/Scenarios/SendKeys.cs

@@ -57,7 +57,7 @@ namespace UICatalog.Scenarios {
 			var IsAlt = false;
 			var IsCtrl = false;
 
-			txtResult.KeyPress += (e) => {
+			txtResult.KeyPress += (s, e) => {
 				rKeys += (char)e.KeyEvent.Key;
 				if (!IsShift && e.KeyEvent.IsShift) {
 					rControlKeys += " Shift ";
@@ -116,7 +116,7 @@ namespace UICatalog.Scenarios {
 
 			button.Clicked += () => ProcessInput ();
 
-			Win.KeyPress += (e) => {
+			Win.KeyPress += (s, e) => {
 				if (e.KeyEvent.Key == Key.Enter) {
 					ProcessInput ();
 					e.Handled = true;

+ 1 - 1
UICatalog/Scenarios/SingleBackgroundWorker.cs

@@ -133,7 +133,7 @@ namespace UICatalog.Scenarios {
 			public StagingUIController (DateTime? start, List<string> list)
 			{
 				top = new Toplevel (Application.Top.Frame);
-				top.KeyPress += (e) => {
+				top.KeyPress += (s,e) => {
 					// Prevents Ctrl+Q from closing this.
 					// Only Ctrl+C is allowed.
 					if (e.KeyEvent.Key == (Key.Q | Key.CtrlMask)) {

+ 1 - 1
UICatalog/Scenarios/TableEditor.cs

@@ -345,7 +345,7 @@ namespace UICatalog.Scenarios {
 
 		}
 
-		private void TableViewKeyPress (View.KeyEventEventArgs e)
+		private void TableViewKeyPress (object sender, View.KeyEventEventArgs e)
 		{
 			if (e.KeyEvent.Key == Key.DeleteChar) {
 

+ 1 - 1
UICatalog/Scenarios/TextAlignmentsAndDirection.cs

@@ -118,7 +118,7 @@ namespace UICatalog.Scenarios {
 				}
 			};
 
-			Win.KeyUp += (m) => {
+			Win.KeyUp += (s, m) => {
 				foreach (var v in txts) {
 					v.Text = editText.Text;
 				}

+ 1 - 1
UICatalog/Scenarios/TextViewAutocompletePopup.cs

@@ -94,7 +94,7 @@ namespace UICatalog.Scenarios {
 			Win.LayoutStarted += Win_LayoutStarted;
 		}
 
-		private void Win_LayoutStarted (View.LayoutEventArgs obj)
+		private void Win_LayoutStarted (object sender, View.LayoutEventArgs obj)
 		{
 			miMultiline.Checked = textViewTopLeft.Multiline;
 			miWrap.Checked = textViewTopLeft.WordWrap;

+ 1 - 1
UICatalog/Scenarios/TreeViewFileSystem.cs

@@ -106,7 +106,7 @@ namespace UICatalog.Scenarios {
 			ShowPropertiesOf (e.NewValue);
 		}
 
-		private void TreeViewFiles_KeyPress (View.KeyEventEventArgs obj)
+		private void TreeViewFiles_KeyPress (object sender, View.KeyEventEventArgs obj)
 		{
 			if (obj.KeyEvent.Key == (Key.R | Key.CtrlMask)) {
 

+ 6 - 6
UICatalog/Scenarios/VkeyPacketSimulator.cs

@@ -88,7 +88,7 @@ namespace UICatalog.Scenarios {
 				ReadOnly = true
 			};
 
-			tvOutput.KeyDown += (e) => {
+			tvOutput.KeyDown += (s, e) => {
 				//System.Diagnostics.Debug.WriteLine ($"Output - KeyDown: {e.KeyEvent.Key}");
 				e.Handled = true;
 				if (e.KeyEvent.Key == Key.Unknown) {
@@ -96,7 +96,7 @@ namespace UICatalog.Scenarios {
 				}
 			};
 
-			tvOutput.KeyPress += (e) => {
+			tvOutput.KeyPress += (s, e) => {
 				//System.Diagnostics.Debug.WriteLine ($"Output - KeyPress - _keyboardStrokes: {_keyboardStrokes.Count}");
 				if (_outputStarted && _keyboardStrokes.Count > 0) {
 					var ev = ShortcutHelper.GetModifiersKey (e.KeyEvent);
@@ -114,7 +114,7 @@ namespace UICatalog.Scenarios {
 
 			Win.Add (tvOutput);
 
-			tvInput.KeyDown += (e) => {
+			tvInput.KeyDown += (s, e) => {
 				//System.Diagnostics.Debug.WriteLine ($"Input - KeyDown: {e.KeyEvent.Key}");
 				e.Handled = true;
 				if (e.KeyEvent.Key == Key.Unknown) {
@@ -124,7 +124,7 @@ namespace UICatalog.Scenarios {
 
 			View.KeyEventEventArgs unknownChar = null;
 
-			tvInput.KeyPress += (e) => {
+			tvInput.KeyPress += (s, e) => {
 				if (e.KeyEvent.Key == (Key.Q | Key.CtrlMask)) {
 					Application.RequestStop ();
 					return;
@@ -152,7 +152,7 @@ namespace UICatalog.Scenarios {
 				//System.Diagnostics.Debug.WriteLine ($"Input - KeyPress - _keyboardStrokes: {_keyboardStrokes.Count}");
 			};
 
-			tvInput.KeyUp += (e) => {
+			tvInput.KeyUp += (s, e) => {
 				//System.Diagnostics.Debug.WriteLine ($"Input - KeyUp: {e.KeyEvent.Key}");
 				//var ke = e.KeyEvent;
 				var ke = ShortcutHelper.GetModifiersKey (e.KeyEvent);
@@ -221,7 +221,7 @@ namespace UICatalog.Scenarios {
 
 			tvInput.SetFocus ();
 
-			Win.LayoutComplete += (_) => {
+			Win.LayoutComplete += (s, e) => {
 				inputHorizontalRuler.Text = outputHorizontalRuler.Text = ruler.Repeat ((int)Math.Ceiling ((double)(inputHorizontalRuler.Bounds.Width) / (double)ruler.Length)) [0..(inputHorizontalRuler.Bounds.Width)];
 				inputVerticalRuler.Height = tvInput.Frame.Height + 1;
 				inputVerticalRuler.Text = ruler.Repeat ((int)Math.Ceiling ((double)(inputVerticalRuler.Bounds.Height) / (double)ruler.Length)) [0..(inputVerticalRuler.Bounds.Height)];

+ 1 - 1
UICatalog/UICatalog.cs

@@ -651,7 +651,7 @@ namespace UICatalog {
 				Application.Top.SetNeedsDisplay ();
 			}
 
-			void KeyDownHandler (View.KeyEventEventArgs a)
+			void KeyDownHandler (object sender, View.KeyEventEventArgs a)
 			{
 				if (a.KeyEvent.IsCapslock) {
 					Capslock.Title = "Caps: On";

+ 1 - 1
UnitTests/Application/ApplicationTests.cs

@@ -582,7 +582,7 @@ namespace Terminal.Gui.ApplicationTests {
 
 			int keyUps = 0;
 			var output = string.Empty;
-			Application.Top.KeyUp += (View.KeyEventEventArgs args) => {
+			Application.Top.KeyUp += (object sender, View.KeyEventEventArgs args) => {
 				if (args.KeyEvent.Key != (Key.CtrlMask | Key.Q)) {
 					output += (char)args.KeyEvent.KeyValue;
 				}

+ 17 - 17
UnitTests/Core/ViewTests.cs

@@ -1134,7 +1134,7 @@ namespace Terminal.Gui.CoreTests {
 			var top = Application.Top;
 
 			var text = new TextField ("");
-			text.KeyPress += (e) => {
+			text.KeyPress += (s, e) => {
 				e.Handled = true;
 				Assert.True (e.Handled);
 				Assert.Equal (Key.N, e.KeyEvent.Key);
@@ -1232,10 +1232,10 @@ namespace Terminal.Gui.CoreTests {
 			Assert.Equal (80, view.Bounds.Width);
 			Assert.Equal (25, view.Bounds.Height);
 			bool layoutStarted = false;
-			view.LayoutStarted += (_) => layoutStarted = true;
+			view.LayoutStarted += (s,e) => layoutStarted = true;
 			view.OnLayoutStarted (null);
 			Assert.True (layoutStarted);
-			view.LayoutComplete += (_) => layoutStarted = false;
+			view.LayoutComplete += (s,e) => layoutStarted = false;
 			view.OnLayoutComplete (null);
 			Assert.False (layoutStarted);
 			view.X = Pos.Center () - 41;
@@ -1539,7 +1539,7 @@ namespace Terminal.Gui.CoreTests {
 			var tf = new TextField ();
 			tf.KeyPress += Tf_KeyPress;
 
-			void Tf_KeyPress (View.KeyEventEventArgs obj)
+			void Tf_KeyPress (object sender, View.KeyEventEventArgs obj)
 			{
 				if (obj.KeyEvent.Key == (Key.Q | Key.CtrlMask)) {
 					obj.Handled = tfQuiting = true;
@@ -1551,7 +1551,7 @@ namespace Terminal.Gui.CoreTests {
 			var top = Application.Top;
 			top.KeyPress += Top_KeyPress;
 
-			void Top_KeyPress (View.KeyEventEventArgs obj)
+			void Top_KeyPress (object sender, View.KeyEventEventArgs obj)
 			{
 				if (obj.KeyEvent.Key == (Key.Q | Key.CtrlMask)) {
 					obj.Handled = topQuiting = true;
@@ -1599,7 +1599,7 @@ namespace Terminal.Gui.CoreTests {
 			var tf = new TextField ();
 			tf.KeyPress += Tf_KeyPress;
 
-			void Tf_KeyPress (View.KeyEventEventArgs obj)
+			void Tf_KeyPress (object sender, View.KeyEventEventArgs obj)
 			{
 				if (obj.KeyEvent.Key == (Key.Q | Key.CtrlMask)) {
 					obj.Handled = tfQuiting = true;
@@ -2287,21 +2287,21 @@ This is a tes
 			var keyUp = false;
 
 			var view = new DerivedView ();
-			view.KeyDown += (e) => {
+			view.KeyDown += (s, e) => {
 				Assert.Equal (Key.a, e.KeyEvent.Key);
 				Assert.False (keyDown);
 				Assert.False (view.IsKeyDown);
 				e.Handled = true;
 				keyDown = true;
 			};
-			view.KeyPress += (e) => {
+			view.KeyPress += (s,e) => {
 				Assert.Equal (Key.a, e.KeyEvent.Key);
 				Assert.False (keyPress);
 				Assert.False (view.IsKeyPress);
 				e.Handled = true;
 				keyPress = true;
 			};
-			view.KeyUp += (e) => {
+			view.KeyUp += (s, e) => {
 				Assert.Equal (Key.a, e.KeyEvent.Key);
 				Assert.False (keyUp);
 				Assert.False (view.IsKeyUp);
@@ -2390,7 +2390,7 @@ This is a tes
 			var keyUp = false;
 
 			var view = new DerivedView ();
-			view.KeyDown += (e) => {
+			view.KeyDown += (s,e) => {
 				Assert.Equal (-1, e.KeyEvent.KeyValue);
 				Assert.Equal (shift, e.KeyEvent.IsShift);
 				Assert.Equal (alt, e.KeyEvent.IsAlt);
@@ -2399,10 +2399,10 @@ This is a tes
 				Assert.False (view.IsKeyDown);
 				keyDown = true;
 			};
-			view.KeyPress += (e) => {
+			view.KeyPress += (s, e) => {
 				keyPress = true;
 			};
-			view.KeyUp += (e) => {
+			view.KeyUp += (s, e) => {
 				Assert.Equal (-1, e.KeyEvent.KeyValue);
 				Assert.Equal (shift, e.KeyEvent.IsShift);
 				Assert.Equal (alt, e.KeyEvent.IsAlt);
@@ -2908,15 +2908,15 @@ At 0,0
 			Assert.Equal (new Rect (0, 0, 30, 1), label.NeedDisplay);
 			Assert.Equal (new Rect (0, 0, 13, 1), button.NeedDisplay);
 
-			top.LayoutComplete += e => {
+			top.LayoutComplete += (s,e) => {
 				Assert.Equal (new Rect (0, 0, 80, 25), top.NeedDisplay);
 			};
 
-			frame.LayoutComplete += e => {
+			frame.LayoutComplete += (s, e) => {
 				Assert.Equal (new Rect (0, 0, 40, 8), frame.NeedDisplay);
 			};
 
-			frame.Subviews [0].LayoutComplete += e => {
+			frame.Subviews [0].LayoutComplete += (s, e) => {
 				if (top.IsLoaded) {
 					Assert.Equal (new Rect (0, 0, 38, 6), frame.Subviews [0].NeedDisplay);
 				} else {
@@ -2924,11 +2924,11 @@ At 0,0
 				}
 			};
 
-			label.LayoutComplete += e => {
+			label.LayoutComplete += (s, e) => {
 				Assert.Equal (new Rect (0, 0, 38, 1), label.NeedDisplay);
 			};
 
-			button.LayoutComplete += e => {
+			button.LayoutComplete += (s, e) => {
 				Assert.Equal (new Rect (0, 0, 13, 1), button.NeedDisplay);
 			};
 

+ 3 - 3
UnitTests/Drivers/ConsoleDriverTests.cs

@@ -82,7 +82,7 @@ namespace Terminal.Gui.DriverTests {
 			var count = 0;
 			var wasKeyPressed = false;
 
-			view.KeyPress += (e) => {
+			view.KeyPress += (s, e) => {
 				wasKeyPressed = true;
 			};
 			top.Add (view);
@@ -121,7 +121,7 @@ namespace Terminal.Gui.DriverTests {
 			var rText = "";
 			var idx = 0;
 
-			view.KeyPress += (e) => {
+			view.KeyPress += (s, e) => {
 				Assert.Equal (text [idx], (char)e.KeyEvent.Key);
 				rText += (char)e.KeyEvent.Key;
 				Assert.Equal (rText, text.Substring (0, idx + 1));
@@ -473,7 +473,7 @@ namespace Terminal.Gui.DriverTests {
 
 			var top = Application.Top;
 
-			top.KeyPress += (e) => {
+			top.KeyPress += (s, e) => {
 				var after = ShortcutHelper.GetModifiersKey (e.KeyEvent);
 				Assert.Equal (expectedRemapping, after);
 				e.Handled = true;

+ 1 - 1
UnitTests/Menus/ContextMenuTests.cs

@@ -175,7 +175,7 @@ namespace Terminal.Gui.MenuTests {
 
 			var cm = new ContextMenu ();
 
-			lbl.KeyPress += (e) => {
+			lbl.KeyPress += (s, e) => {
 				if (e.KeyEvent.Key == cm.Key) {
 					lbl.Text = "Replaced";
 					e.Handled = true;

+ 1 - 1
UnitTests/TopLevels/ToplevelTests.cs

@@ -1060,7 +1060,7 @@ namespace Terminal.Gui.TopLevelTests {
 
 			view.LayoutStarted += view_LayoutStarted;
 
-			void view_LayoutStarted (View.LayoutEventArgs e)
+			void view_LayoutStarted (object sender, View.LayoutEventArgs e)
 			{
 				Assert.Equal (new Rect (0, 0, 20, 10), view.NeedDisplay);
 				view.LayoutStarted -= view_LayoutStarted;

+ 4 - 4
UnitTests/Types/DimTests.cs

@@ -629,7 +629,7 @@ namespace Terminal.Gui.TypeTests {
 			var field = new TextField () { X = 0, Y = Pos.Bottom (view), Width = 20 };
 			var count = 0;
 
-			field.KeyDown += (k) => {
+			field.KeyDown += (s, k) => {
 				if (k.KeyEvent.Key == Key.Enter) {
 					field.Text = $"Label {count}";
 					var label = new Label (field.Text) { X = 0, Y = view.Bounds.Height, Width = 20 };
@@ -996,7 +996,7 @@ namespace Terminal.Gui.TypeTests {
 			var count = 0;
 			var listLabels = new List<Label> ();
 
-			field.KeyDown += (k) => {
+			field.KeyDown += (s, k) => {
 				if (k.KeyEvent.Key == Key.Enter) {
 					((FakeDriver)Application.Driver).SetBufferSize (22, count + 4);
 					var pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], output);
@@ -1075,7 +1075,7 @@ namespace Terminal.Gui.TypeTests {
 				Assert.Equal ($"Absolute({i + 1})", view.Height.ToString ());
 			}
 
-			field.KeyDown += (k) => {
+			field.KeyDown += (s, k) => {
 				if (k.KeyEvent.Key == Key.Enter) {
 					Assert.Equal ($"Label {count - 1}", listLabels [count - 1].Text);
 					view.Remove (listLabels [count - 1]);
@@ -1140,7 +1140,7 @@ namespace Terminal.Gui.TypeTests {
 				}
 			}
 
-			field.KeyDown += (k) => {
+			field.KeyDown += (s, k) => {
 				if (k.KeyEvent.Key == Key.Enter) {
 					((FakeDriver)Application.Driver).SetBufferSize (22, count + 4);
 					var pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], output);

+ 2 - 2
UnitTests/Types/PosTests.cs

@@ -875,7 +875,7 @@ namespace Terminal.Gui.TypeTests {
 			var field = new TextField () { X = 0, Y = 0, Width = 20 };
 			var count = 0;
 
-			field.KeyDown += (k) => {
+			field.KeyDown += (s, k) => {
 				if (k.KeyEvent.Key == Key.Enter) {
 					field.Text = $"Label {count}";
 					var label = new Label (field.Text) { X = 0, Y = field.Y, Width = 20 };
@@ -936,7 +936,7 @@ namespace Terminal.Gui.TypeTests {
 				Assert.Equal ($"Absolute({i + 1})", field.Y.ToString ());
 			}
 
-			field.KeyDown += (k) => {
+			field.KeyDown += (s, k) => {
 				if (k.KeyEvent.Key == Key.Enter) {
 					Assert.Equal ($"Label {count - 1}", listLabels [count - 1].Text);
 					view.Remove (listLabels [count - 1]);

+ 2 - 2
UnitTests/UICatalog/ScenarioTests.cs

@@ -121,7 +121,7 @@ namespace UICatalog.Tests {
 			};
 			var token = Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (ms), abortCallback);
 
-			Application.Top.KeyPress += (View.KeyEventEventArgs args) => {
+			Application.Top.KeyPress += (object sender, View.KeyEventEventArgs args) => {
 				Assert.Equal (Key.CtrlMask | Key.Q, args.KeyEvent.Key);
 			};
 
@@ -563,7 +563,7 @@ namespace UICatalog.Tests {
 				return view;
 			}
 
-			void LayoutCompleteHandler (View.LayoutEventArgs args)
+			void LayoutCompleteHandler (object sender, View.LayoutEventArgs args)
 			{
 				UpdateTitle (_curView);
 			}