[A] Adjust Entry to avoid skipping upon completion via Enter key (#1090)

This commit is contained in:
Paul DiPietro 2017-11-08 07:39:58 -05:00 коммит произвёл Rui Marinho
Родитель 8c12e05ef0
Коммит e2c6b0b655
3 изменённых файлов: 43 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,41 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 52299, "[Android] Using a physical keyboard, setting Focus from an Entry's Completed handler fails", PlatformAffected.Android)]
public class Bugzilla52299 : TestContentPage
{
protected override void Init()
{
var entry = new Entry { Placeholder = "One" };
var entry2 = new Entry { Placeholder = "Two" };
var entry3 = new Entry { Placeholder = "Three" };
var entry4 = new Entry { Placeholder = "Four" };
entry.Completed += (s, e) => { entry2.Focus(); };
entry2.Completed += (s, e) => { entry3.Focus(); };
entry3.Completed += (s, e) => { entry4.Focus(); };
Content = new ScrollView
{
Content = new StackLayout
{
Children =
{
new Label { Text = "Pressing Enter on a physical keyboard should not make the entry skip (e.g. One -> Three)" },
entry,
entry2,
entry3,
entry4
}
}
};
}
}
}

Просмотреть файл

@ -173,6 +173,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla46363.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla46363_2.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla47548.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla52299.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla52419.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla53834.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla51536.cs" />

Просмотреть файл

@ -34,7 +34,7 @@ namespace Xamarin.Forms.Platform.Android
bool TextView.IOnEditorActionListener.OnEditorAction(TextView v, ImeAction actionId, KeyEvent e)
{
// Fire Completed and dismiss keyboard for hardware / physical keyboards
if (actionId == ImeAction.Done || (actionId == ImeAction.ImeNull && e.KeyCode == Keycode.Enter))
if (actionId == ImeAction.Done || (actionId == ImeAction.ImeNull && e.KeyCode == Keycode.Enter && e.Action == KeyEventActions.Up))
{
Control.ClearFocus();
v.HideKeyboard();