diff --git a/Wox/HotkeyControl.xaml.cs b/Wox/HotkeyControl.xaml.cs
index 73b16f033b..135769c743 100644
--- a/Wox/HotkeyControl.xaml.cs
+++ b/Wox/HotkeyControl.xaml.cs
@@ -108,5 +108,10 @@ namespace Wox
return false;
}
+
+ public new bool IsFocused
+ {
+ get { return tbHotkey.IsFocused; }
+ }
}
}
diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml
index 4b5a39336f..ac40627a54 100644
--- a/Wox/SettingWindow.xaml
+++ b/Wox/SettingWindow.xaml
@@ -11,7 +11,7 @@
Title="{DynamicResource woxsettings}"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
- Height="600" Width="800">
+ Height="600" Width="800" PreviewKeyDown="Window_PreviewKeyDown">
-
+
@@ -45,7 +45,7 @@
-
+
@@ -121,7 +121,7 @@
-
+
@@ -201,7 +201,7 @@
-
+
diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs
index 319c45bc48..daa6d60d24 100644
--- a/Wox/SettingWindow.xaml.cs
+++ b/Wox/SettingWindow.xaml.cs
@@ -164,6 +164,24 @@ namespace Wox
}
}
+ private void settingTab_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ // Update controls inside the selected tab
+
+ if (tabPlugin.IsSelected)
+ {
+ OnPluginTabSelected();
+ }
+ else if (tabTheme.IsSelected)
+ {
+ OnThemeTabSelected();
+ }
+ else if (tabHotkey.IsSelected)
+ {
+ OnHotkeyTabSelected();
+ }
+ }
+
#region General
private void LoadLanguages()
@@ -243,17 +261,6 @@ namespace Wox
}
}
-
- private void TabHotkey_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- var tabItem = sender as TabItem;
- var clickingBody = (tabItem.Content as UIElement).IsMouseOver;
- if (!clickingBody)
- {
- OnHotkeyTabSelected();
- }
- }
-
private void OnHotkeyTabSelected()
{
ctlHotkey.HotkeyChanged += ctlHotkey_OnHotkeyChanged;
@@ -422,16 +429,6 @@ namespace Wox
}
- private void TabTheme_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- var tabItem = sender as TabItem;
- var clickingBody = (tabItem.Content as UIElement).IsMouseOver;
- if (!clickingBody)
- {
- OnThemeTabSelected();
- }
- }
-
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
string themeName = themeComboBox.SelectedItem.ToString();
@@ -666,17 +663,6 @@ namespace Wox
lbPlugins.SelectedIndex = 0;
}
- private void TabPlugin_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- var tabItem = sender as TabItem;
- var clickingBody = (tabItem.Content as UIElement).IsMouseOver;
- if (!clickingBody)
- {
- OnPluginTabSelected();
- }
- }
-
-
#endregion
#region Proxy
@@ -788,5 +774,14 @@ namespace Wox
}
#endregion
+
+ private void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
+ {
+ // Hide window with ESC, but make sure it is not pressed as a hotkey
+ if (e.Key == Key.Escape && !ctlHotkey.IsFocused)
+ {
+ Close();
+ }
+ }
}
}