mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
Fix #706 , bug introduced in 2a3bf727be1c8bc185f1b436893b1c4385d982ac
This commit is contained in:
@@ -20,13 +20,10 @@
|
|||||||
Closing="OnClosing"
|
Closing="OnClosing"
|
||||||
Drop="OnDrop"
|
Drop="OnDrop"
|
||||||
SizeChanged="OnSizeChanged"
|
SizeChanged="OnSizeChanged"
|
||||||
IsVisibleChanged="OnMainWindowVisible"
|
|
||||||
Deactivated="OnDeactivated"
|
Deactivated="OnDeactivated"
|
||||||
PreviewKeyDown="OnKeyDown"
|
PreviewKeyDown="OnKeyDown"
|
||||||
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
d:DataContext="{d:DesignInstance vm:MainViewModel}"
|
d:DataContext="{d:DesignInstance vm:MainViewModel}">
|
||||||
FocusManager.FocusedElement="{Binding ElementName=QueryTextBox}"
|
|
||||||
FocusManager.IsFocusScope="True">
|
|
||||||
<Window.InputBindings>
|
<Window.InputBindings>
|
||||||
<KeyBinding Key="Escape" Command="{Binding EscCommand}"></KeyBinding>
|
<KeyBinding Key="Escape" Command="{Binding EscCommand}"></KeyBinding>
|
||||||
<KeyBinding Key="F1" Command="{Binding StartHelpCommand}"></KeyBinding>
|
<KeyBinding Key="F1" Command="{Binding StartHelpCommand}"></KeyBinding>
|
||||||
@@ -56,10 +53,7 @@
|
|||||||
<TextBox Style="{DynamicResource QueryBoxStyle}"
|
<TextBox Style="{DynamicResource QueryBoxStyle}"
|
||||||
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
PreviewDragOver="OnPreviewDragOver"
|
PreviewDragOver="OnPreviewDragOver"
|
||||||
IsVisibleChanged="OnQueryVisible"
|
|
||||||
TextChanged="OnQueryChanged"
|
|
||||||
AllowDrop="True"
|
AllowDrop="True"
|
||||||
Focusable="True"
|
|
||||||
Visibility="Visible"
|
Visibility="Visible"
|
||||||
x:Name="QueryTextBox">
|
x:Name="QueryTextBox">
|
||||||
<TextBox.ContextMenu>
|
<TextBox.ContextMenu>
|
||||||
|
|||||||
@@ -51,6 +51,29 @@ namespace Wox
|
|||||||
WindowIntelopHelper.DisableControlBox(this);
|
WindowIntelopHelper.DisableControlBox(this);
|
||||||
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
||||||
InitializeNotifyIcon();
|
InitializeNotifyIcon();
|
||||||
|
InitProgressbarAnimation();
|
||||||
|
|
||||||
|
_viewModel.PropertyChanged += (o, e) =>
|
||||||
|
{
|
||||||
|
if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
|
||||||
|
{
|
||||||
|
if (_viewModel.MainWindowVisibility.IsVisible())
|
||||||
|
{
|
||||||
|
Activate();
|
||||||
|
QueryTextBox.Focus();
|
||||||
|
SetWindowPosition();
|
||||||
|
_settings.ActivateTimes++;
|
||||||
|
if (_viewModel.QueryTextSelected)
|
||||||
|
{
|
||||||
|
QueryTextBox.SelectAll();
|
||||||
|
_viewModel.QueryTextSelected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// since the default main window visibility is visible
|
||||||
|
// so we need set focus during startup
|
||||||
|
QueryTextBox.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeNotifyIcon()
|
private void InitializeNotifyIcon()
|
||||||
@@ -145,38 +168,6 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnQueryVisible(object sender, DependencyPropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
var visible = (bool)e.NewValue;
|
|
||||||
if (visible)
|
|
||||||
{
|
|
||||||
// the Focusable and the IsVisible both needs to be true when set focus
|
|
||||||
// logical is set in xaml
|
|
||||||
QueryTextBox.Focus();
|
|
||||||
|
|
||||||
if (_viewModel.QueryTextSelected)
|
|
||||||
{
|
|
||||||
QueryTextBox.SelectAll();
|
|
||||||
_viewModel.QueryTextSelected = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnQueryChanged(object sender, TextChangedEventArgs e)
|
|
||||||
{
|
|
||||||
QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnMainWindowVisible(object sender, DependencyPropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
var visible = (bool)e.NewValue;
|
|
||||||
if (visible)
|
|
||||||
{
|
|
||||||
SetWindowPosition();
|
|
||||||
_settings.ActivateTimes++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _startup = true;
|
private bool _startup = true;
|
||||||
private void SetWindowPosition()
|
private void SetWindowPosition()
|
||||||
{
|
{
|
||||||
@@ -191,8 +182,6 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
// used to set correct position on windows first startup
|
// used to set correct position on windows first startup
|
||||||
// since the actual width and actual height will be avaiable after this event
|
// since the actual width and actual height will be avaiable after this event
|
||||||
@@ -201,7 +190,6 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
Left = WindowLeft();
|
Left = WindowLeft();
|
||||||
Top = WindowTop();
|
Top = WindowTop();
|
||||||
InitProgressbarAnimation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private double WindowLeft()
|
private double WindowLeft()
|
||||||
@@ -239,7 +227,5 @@ namespace Wox
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user