From e787bf3f4c91259d86e30145b4c7d3a2a9e90a3c Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 8 Aug 2015 13:37:42 +0200 Subject: [PATCH] Close DropDown on Escape. --- Perspex.Controls/DropDown.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Perspex.Controls/DropDown.cs b/Perspex.Controls/DropDown.cs index 69ac54bb75..3116b1d53f 100644 --- a/Perspex.Controls/DropDown.cs +++ b/Perspex.Controls/DropDown.cs @@ -71,11 +71,19 @@ namespace Perspex.Controls { base.OnKeyDown(e); - if (!e.Handled && - (e.Key == Key.F4 || (e.Key == Key.Down && ((e.Device.Modifiers & ModifierKeys.Alt) != 0)))) + if (!e.Handled) { - this.IsDropDownOpen = !this.IsDropDownOpen; - e.Handled = true; + if (e.Key == Key.F4 || + (e.Key == Key.Down && ((e.Device.Modifiers & ModifierKeys.Alt) != 0))) + { + this.IsDropDownOpen = !this.IsDropDownOpen; + e.Handled = true; + } + else if (e.Key == Key.Escape) + { + this.IsDropDownOpen = false; + e.Handled = true; + } } }