From 3adc3ed5d2712a6831baec068df20709331488cf Mon Sep 17 00:00:00 2001 From: bao-qian Date: Fri, 26 Feb 2016 21:34:27 +0000 Subject: [PATCH] Fix textbox keyboard focusing --- Wox/MainWindow.xaml | 2 +- Wox/MainWindow.xaml.cs | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Wox/MainWindow.xaml b/Wox/MainWindow.xaml index f0a1b2843c..49c750c910 100644 --- a/Wox/MainWindow.xaml +++ b/Wox/MainWindow.xaml @@ -29,7 +29,7 @@ + x:Name="QueryTextBox" /> diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index d7da58b72e..0b11d67726 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -58,12 +58,12 @@ namespace Wox { if (vm.SelectAllText) { - tbQuery.SelectAll(); + QueryTextBox.SelectAll(); } } else if(eve.PropertyName == "CaretIndex") { - tbQuery.CaretIndex = vm.CaretIndex; + QueryTextBox.CaretIndex = vm.CaretIndex; } else if(eve.PropertyName == "Left") { @@ -73,20 +73,19 @@ namespace Wox { Top = vm.Top; } - else if(eve.PropertyName == "IsVisible") + else if(eve.PropertyName == "MainWindowVisibility") { if (vm.MainWindowVisibility.IsVisible()) { - tbQuery.Focus(); + Activate(); + QueryTextBox.Focus(); } } }; vm.Left = GetWindowsLeft(); vm.Top = GetWindowsTop(); - Activate(); - Focus(); - tbQuery.Focus(); + vm.MainWindowVisibility = Visibility.Visible; } private double GetWindowsLeft() @@ -105,7 +104,7 @@ namespace Wox var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var dipPoint = WindowIntelopHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height); - UserSettingStorage.Instance.WindowTop = (dipPoint.Y - tbQuery.ActualHeight)/4; + UserSettingStorage.Instance.WindowTop = (dipPoint.Y - QueryTextBox.ActualHeight)/4; return UserSettingStorage.Instance.WindowTop; }