diff options
author | Paul DiPietro <pauldipietro@users.noreply.github.com> | 2016-06-16 12:17:18 -0400 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-06-16 17:17:18 +0100 |
commit | ed517a3027fb8a273b1f4226622cf88378091cd9 (patch) | |
tree | e2c31724dd83f76c31d50e4046bc4957495fd4ad /Xamarin.Forms.Platform.WinRT | |
parent | d5be2f0144ca810fdfbf59808d526c26fe86017e (diff) | |
download | xamarin-forms-ed517a3027fb8a273b1f4226622cf88378091cd9.tar.gz xamarin-forms-ed517a3027fb8a273b1f4226622cf88378091cd9.tar.bz2 xamarin-forms-ed517a3027fb8a273b1f4226622cf88378091cd9.zip |
[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.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/Platform.cs b/Xamarin.Forms.Platform.WinRT/Platform.cs index 6c158a05..311186b2 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) |