diff --git a/CefFlashBrowser/CefFlashBrowser.csproj b/CefFlashBrowser/CefFlashBrowser.csproj index 76e3384..ba0849b 100644 --- a/CefFlashBrowser/CefFlashBrowser.csproj +++ b/CefFlashBrowser/CefFlashBrowser.csproj @@ -286,6 +286,7 @@ + diff --git a/CefFlashBrowser/Utils/Behaviors/EscToCloseBehavior.cs b/CefFlashBrowser/Utils/Behaviors/EscToCloseBehavior.cs new file mode 100644 index 0000000..fad59c2 --- /dev/null +++ b/CefFlashBrowser/Utils/Behaviors/EscToCloseBehavior.cs @@ -0,0 +1,27 @@ +using Microsoft.Xaml.Behaviors; +using System.Windows; +using System.Windows.Input; + +namespace CefFlashBrowser.Utils.Behaviors +{ + public class EscToCloseBehavior : Behavior + { + protected override void OnAttached() + { + AssociatedObject.KeyDown += KeyDownHandler; + } + + protected override void OnDetaching() + { + AssociatedObject.KeyDown -= KeyDownHandler; + } + + private void KeyDownHandler(object sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) + { + AssociatedObject.Close(); + } + } + } +} diff --git a/CefFlashBrowser/Views/Dialogs/AddFavoriteDialog.xaml b/CefFlashBrowser/Views/Dialogs/AddFavoriteDialog.xaml index 158a69d..f931afa 100644 --- a/CefFlashBrowser/Views/Dialogs/AddFavoriteDialog.xaml +++ b/CefFlashBrowser/Views/Dialogs/AddFavoriteDialog.xaml @@ -18,6 +18,10 @@ Title="{DynamicResource title_addFavorite}" FocusManager.FocusedElement="{Binding ElementName=NameTextBox}"> + + + +