summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2016-07-26 12:01:01 -0500
committerSamantha Houts <samantha@teamredwall.com>2016-07-26 10:01:01 -0700
commitea01c07aa32e39e947104253a44566dded50123e (patch)
tree047eed671ea1f34886a772a6ee273b9a2213213c /Xamarin.Forms.Platform.Android
parentd04a4a3cf23c51d8401364d13b9201bf27873618 (diff)
downloadxamarin-forms-ea01c07aa32e39e947104253a44566dded50123e.tar.gz
xamarin-forms-ea01c07aa32e39e947104253a44566dded50123e.tar.bz2
xamarin-forms-ea01c07aa32e39e947104253a44566dded50123e.zip
[Android] Fix focus/unfocus behavior on both Picker renderers (#264)
On AppCompat, focus and unfocus would not trigger when using the Picker. On pre-Lollipop, unfocus would not trigger, but only when tapping outside of the dialog.
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs3
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs7
2 files changed, 9 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs
index 9e81cf2d..6650d9e6 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs
@@ -102,12 +102,15 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
builder.SetItems(items, (s, e) => ((IElementController)model).SetValueFromRenderer(Picker.SelectedIndexProperty, e.Which));
builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { });
+
+ ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
_dialog = builder.Create();
}
_dialog.SetCanceledOnTouchOutside(true);
_dialog.DismissEvent += (sender, args) =>
{
+ ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
_dialog.Dispose();
_dialog = null;
};
diff --git a/Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs
index 57d93b8f..f2abe9d3 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs
@@ -133,7 +133,12 @@ namespace Xamarin.Forms.Platform.Android
_dialog = null;
});
- (_dialog = builder.Create()).Show();
+ _dialog = builder.Create();
+ _dialog.DismissEvent += (sender, args) =>
+ {
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ };
+ _dialog.Show();
}
void RowsCollectionChanged(object sender, EventArgs e)