[iOS] Entry should not pass a newline to the next responder (#397)
authoradrianknight89 <adrianknight89@outlook.com>
Thu, 22 Dec 2016 18:46:57 +0000 (12:46 -0600)
committerJason Smith <jason.smith@xamarin.com>
Thu, 22 Dec 2016 18:46:57 +0000 (10:46 -0800)
* UITextField should not return so that the next field does not get passed a newline

* Added code sample

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla33248.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Platform.iOS/Renderers/EntryRenderer.cs

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla33248.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla33248.cs
new file mode 100644 (file)
index 0000000..8f97231
--- /dev/null
@@ -0,0 +1,53 @@
+using System;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using NUnit.Framework;
+using Xamarin.UITest;
+
+#endif
+
+namespace Xamarin.Forms.Controls.TestCasesPages
+{
+       [Preserve(AllMembers = true)]
+       [Issue(IssueTracker.Bugzilla, 33248, "Entry.Completed calling Editor.Focus() inserts new line to the focused Editor in iOS", PlatformAffected.iOS)]
+       public class Bugzilla33248 : TestContentPage
+       {
+               protected override void Init()
+               {
+                       var editor = new Editor
+                       {
+                               BackgroundColor = Color.Yellow,
+                               HeightRequest = 300
+                       };
+                       var entry = new Entry
+                       {
+                               BackgroundColor = Color.Red,
+                               HeightRequest = 100
+                       };
+
+                       entry.Completed += (sender, e) => editor.Focus();
+
+                       Content = new StackLayout
+                       {
+                               VerticalOptions = LayoutOptions.Start,
+                               Children =
+                               {
+                                       new Label
+                                       {
+                                               HorizontalTextAlignment = TextAlignment.Center,
+                                               Text = "Entry:"
+                                       },
+                                       entry,
+                                       new Label
+                                       {
+                                               HorizontalTextAlignment = TextAlignment.Center,
+                                               Text = "Editor:"
+                                       },
+                                       editor
+                               }
+                       };
+               }
+       }
+}
\ No newline at end of file
index a420489..fe0df14 100644 (file)
@@ -55,6 +55,7 @@
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="$(MSBuildThisFileDirectory)Bugzilla32847.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)Bugzilla33248.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Bugzilla33268.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Bugzilla33612.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Bugzilla33714.cs" />
index e4536cf..a50a4e7 100644 (file)
@@ -124,7 +124,7 @@ namespace Xamarin.Forms.Platform.iOS
                {
                        Control.ResignFirstResponder();
                        ((IEntryController)Element).SendCompleted();
-                       return true;
+                       return false;
                }
 
                void UpdateAlignment()