summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Marinho <me@ruimarinho.net>2016-03-29 17:15:54 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-03-29 17:15:54 (GMT)
commit57b0f3ab3080928d2ddd2da58fc84ef7023c3651 (patch)
treec587604fc9805b677e94c749788d011a36ce0a41
parent0e03738adefaa1accd733e817d7730f2c9b82534 (diff)
parent11dc5a5aca2842346759022fc405e89d1d0132b1 (diff)
downloadxamarin-forms-57b0f3ab3080928d2ddd2da58fc84ef7023c3651.zip
xamarin-forms-57b0f3ab3080928d2ddd2da58fc84ef7023c3651.tar.gz
xamarin-forms-57b0f3ab3080928d2ddd2da58fc84ef7023c3651.tar.bz2
Merge pull request #21 from xamarin/fix-bz39702
[A]Resolve issue where calling Focus in an unfocus event would fail
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39702.cs27
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.Android/PlatformRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.Android/ViewRenderer.cs14
5 files changed, 43 insertions, 3 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39702.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39702.cs
new file mode 100644
index 0000000..8b6bb85
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39702.cs
@@ -0,0 +1,27 @@
+´╗┐using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 39702, "Cannot enter text when Entry is focus()'d from an editor completed event")]
+ public class Bugzilla39702 : TestContentPage // or TestMasterDetailPage, etc ...
+ {
+ protected override void Init()
+ {
+ Title = "focus test";
+ var editor = new Editor();
+ var entry = new Entry();
+
+ editor.Unfocused += (object sender, FocusEventArgs e) => entry.Focus();
+
+ Content = new StackLayout
+ {
+ Children =
+ {
+ editor,
+ entry
+ }
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 81a6c2e..75ace12 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -83,6 +83,7 @@
<DependentUpon>Bugzilla39463.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla39702.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34727.cs" />
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
index 7edbffb..dd1c033 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
@@ -625,6 +625,8 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
});
}
+ Context.HideKeyboard(this);
+
// 200ms is how long the animations are, and they are "reversible" in the sense that starting another one slightly before it's done is fine
return tcs.Task;
diff --git a/Xamarin.Forms.Platform.Android/PlatformRenderer.cs b/Xamarin.Forms.Platform.Android/PlatformRenderer.cs
index 4fbc029..f31b070 100644
--- a/Xamarin.Forms.Platform.Android/PlatformRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/PlatformRenderer.cs
@@ -61,7 +61,7 @@ namespace Xamarin.Forms.Platform.Android
break;
Context.HideKeyboard(currentView);
- RequestFocus();
+ ((Activity)Context).Window.DecorView.ClearFocus();
} while (false);
return result;
diff --git a/Xamarin.Forms.Platform.Android/ViewRenderer.cs b/Xamarin.Forms.Platform.Android/ViewRenderer.cs
index f5c094b..0415ce9 100644
--- a/Xamarin.Forms.Platform.Android/ViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/ViewRenderer.cs
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using Android.App;
+using Android.OS;
using Android.Views;
using AView = Android.Views.View;
@@ -149,11 +150,20 @@ namespace Xamarin.Forms.Platform.Android
if (Control == null)
return;
+ e.Result = true;
+
if (e.Focus)
- e.Result = Control.RequestFocus();
+ {
+ // use post being BeginInvokeOnMainThread will not delay on android
+ Looper looper = Context.MainLooper;
+ var handler = new Handler(looper);
+ handler.Post(() =>
+ {
+ Control?.RequestFocus();
+ });
+ }
else
{
- e.Result = true;
Control.ClearFocus();
}