summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2016-06-16 16:17:18 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-06-16 16:17:18 (GMT)
commited517a3027fb8a273b1f4226622cf88378091cd9 (patch)
treee2c31724dd83f76c31d50e4046bc4957495fd4ad /Xamarin.Forms.Platform.WinRT
parentd5be2f0144ca810fdfbf59808d526c26fe86017e (diff)
downloadxamarin-forms-ed517a3027fb8a273b1f4226622cf88378091cd9.zip
xamarin-forms-ed517a3027fb8a273b1f4226622cf88378091cd9.tar.gz
xamarin-forms-ed517a3027fb8a273b1f4226622cf88378091cd9.tar.bz2
[UWP] Escape key returns ActionSheet result (#208)
When awaiting a DisplayActionSheet in UWP, pressing the escape key with the ActionSheet open would dismiss the dialog but not return a result.
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT')
-rw-r--r--Xamarin.Forms.Platform.WinRT/Platform.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/Platform.cs b/Xamarin.Forms.Platform.WinRT/Platform.cs
index 6c158a0..311186b 100644
--- a/Xamarin.Forms.Platform.WinRT/Platform.cs
+++ b/Xamarin.Forms.Platform.WinRT/Platform.cs
@@ -13,7 +13,9 @@ using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
#if WINDOWS_UWP
+using Windows.Foundation;
using Windows.Foundation.Metadata;
+using Windows.UI.Core;
using Windows.UI.ViewManagement;
#endif
@@ -591,6 +593,17 @@ namespace Xamarin.Forms.Platform.WinRT
options.SetResult((string)e.ClickedItem);
};
+ TypedEventHandler<CoreWindow, CharacterReceivedEventArgs> onEscapeButtonPressed = delegate(CoreWindow window, CharacterReceivedEventArgs args)
+ {
+ if (args.KeyCode == 27)
+ {
+ dialog.Hide();
+ options.SetResult(ContentDialogResult.None.ToString());
+ }
+ };
+
+ Window.Current.CoreWindow.CharacterReceived += onEscapeButtonPressed;
+
_actionSheetOptions = options;
if (options.Cancel != null)
@@ -604,6 +617,8 @@ namespace Xamarin.Forms.Platform.WinRT
options.SetResult(options.Cancel);
else if (result == ContentDialogResult.Primary)
options.SetResult(options.Destruction);
+
+ Window.Current.CoreWindow.CharacterReceived -= onEscapeButtonPressed;
}
#else
void OnPageActionSheet(Page sender, ActionSheetArguments options)