Repository: gui-cs/Terminal.Gui

Issue:
Pressing the ENTER key in a TextField should not move the focus 
**Describe the bug**

Pressing the ENTER key in a TextField should not move the focus away from the TextField.

**To Reproduce**

Steps to reproduce the behavior:
1. Use the example at https://github.com/gui-cs/Terminal.Gui#sample-usage-in-c
2. Press the ENTER key (in the username TextField, which should be focused by default).
3. See that the cursor/focus is not in the TextField anymore

**Expected behavior**

I expected the focus to remain in the TextField where I've pressed the ENTER key.




Hints:
That is the expected behavior if the button is set as default. If you set `IsDefault = false`, then the `Textfield` wouldn't loss the focus.
With `IsDefault = false`, pressing the ENTER key in the `TextField` would still trigger the default button action? If not, I do not want to do that, as that looses the ability to trigger the default button action.

IMHO, the expected behavior should be like Windows Forms control, where it does not loose focus.
> With `IsDefault = false`, pressing the ENTER key in the `TextField` would still trigger the default button action?

No, if it's false then will not trigger the button action and the `TextField` maintain the focus.
Ah, so I do not want to do that, as that looses the ability to trigger the default button action. IMHO, it should behave be like Windows Forms, where it does not loose focus. That is a much better user experience than having the focus unexpectedly bouncing to the button.
When the button is default it will get the focus but it can focus again the previous focused view with some change to the button action, It's a suggestion to do that feature :-)
In `Button.cs` it's only need do change like this:

```cs
		///<inheritdoc/>
		public override bool ProcessColdKey (KeyEvent kb)
		{
			if (!Enabled) {
				return false;
			}

			var focused = SuperView?.MostFocused;
			var res = ExecuteColdKey (kb);
			focused?.SetFocus ();
			return res;
		}

```
I believe this is addressed. Closing. Reopen if you disagree. 
@tig why do you believe its addressed? was there a commit about this?

Patch:
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index c5995f838d..0c90c13b8e 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -129,6 +129,10 @@ void Initialize (ustring text, bool is_default)
 		/// Gets or sets whether the <see cref="Button"/> is the default action to activate in a dialog.
 		/// </summary>
 		/// <value><c>true</c> if is default; otherwise, <c>false</c>.</value>
+		/// <remarks>
+		/// If is <see langword="true"/> the current focused view
+		/// will remain focused if the window is not closed.
+		/// </remarks>
 		public bool IsDefault {
 			get => is_default;
 			set {
@@ -219,7 +223,7 @@ bool ExecuteColdKey (KeyEvent ke)
 
 		bool AcceptKey ()
 		{
-			if (!HasFocus) {
+			if (!IsDefault && !HasFocus) {
 				SetFocus ();
 			}
 			OnClicked ();
diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs
index 0202db0e3b..5ef99cfa80 100644
--- a/UnitTests/Views/ButtonTests.cs
+++ b/UnitTests/Views/ButtonTests.cs
@@ -585,5 +585,21 @@ public void Pos_Center_Layout_AutoSize_False ()
 
 			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
 		}
+
+		[Fact, AutoInitShutdown]
+		public void IsDefault_True_Does_Not_Get_The_Focus_On_Enter_Key ()
+		{
+			var wasClicked = false;
+			var view = new View { CanFocus = true };
+			var btn = new Button { Text = "Ok", IsDefault = true };
+			btn.Clicked += () => wasClicked = true;
+			Application.Top.Add (view, btn);
+			Application.Begin (Application.Top);
+			Assert.True (view.HasFocus);
+
+			Application.Top.ProcessColdKey (new KeyEvent (Key.Enter, new KeyModifiers ()));
+			Assert.True (view.HasFocus);
+			Assert.True (wasClicked);
+		}
 	}
 }


Test patch:
diff --git a/testenvironments.json b/testenvironments.json
index 898ac827de..25324739d6 100644
--- a/testenvironments.json
+++ b/testenvironments.json
@@ -10,6 +10,11 @@
 			"type": "wsl",
 			"wslDistribution": "Ubuntu"
 		},
+		{
+			"name": "WSL-Ubuntu-20.04",
+			"type": "wsl",
+			"wslDistribution": "Ubuntu-20.04"
+		},
 		{
 			"name": "WSL-Debian",
 			"type": "wsl",