зеркало из https://github.com/DeGsoft/maui-linux.git
[iOS] Picker no longer allows arbitrary text to be typed with keyboard (#996)
* Add repro * [iOS] Reset text on editing * Add instructions, fix test case number
This commit is contained in:
Родитель
f5caf6881f
Коммит
ec75b998fa
|
@ -0,0 +1,22 @@
|
|||
using System.Linq;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Bugzilla, 37285, "Possible to enter text into Picker control", PlatformAffected.iOS)]
|
||||
public class Bugzilla37285 : TestContentPage
|
||||
{
|
||||
const string Instructions = "On iOS, focus the Picker below and type with a hardware keyboard. If text appears in the Picker text view, this test has failed. Note that Windows will allow you to select items with the keyboard, but the text you type will not appear in the text view. Also note that Android will allow you to select an item using the arrow and enter keys, but again, no text will appear in the text view.";
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
var picker = new Picker { ItemsSource = Enumerable.Range(0, 100).Select(c => c.ToString()).ToList() };
|
||||
|
||||
var stack = new StackLayout { Children = { new Label { Text = Instructions }, picker } };
|
||||
|
||||
Content = stack;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,6 +86,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla36703.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla36846.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla36955.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla37285.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla37462.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla37841.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla37863.cs" />
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
|
||||
entry.EditingDidBegin += OnStarted;
|
||||
entry.EditingDidEnd += OnEnded;
|
||||
entry.EditingChanged += OnEditing;
|
||||
|
||||
_picker = new UIPickerView();
|
||||
|
||||
|
@ -75,6 +76,14 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
UpdateTextColor();
|
||||
}
|
||||
|
||||
void OnEditing(object sender, EventArgs eventArgs)
|
||||
{
|
||||
// Reset the TextField's Text so it appears as if typing with a keyboard does not work.
|
||||
var selectedIndex = Element.SelectedIndex;
|
||||
var items = Element.Items;
|
||||
Control.Text = selectedIndex == -1 || items == null ? "" : items[selectedIndex];
|
||||
}
|
||||
|
||||
void OnEnded(object sender, EventArgs eventArgs)
|
||||
{
|
||||
ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче