fix: can not type in command palette

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2026-03-09 17:24:28 +08:00
parent 4d88ae2d13
commit e71c5f2751
2 changed files with 8 additions and 20 deletions

View File

@@ -127,9 +127,7 @@
<Border Grid.Row="0" Grid.RowSpan="2"
Background="Transparent"
IsVisible="{Binding CommandPalette, Converter={x:Static ObjectConverters.IsNotNull}}"
PointerPressed="OnCloseCommandPalette"
KeyDown="OnCommandPaletteKeyDown"
KeyUp="OnCommandPaletteKeyUp">
PointerPressed="OnCloseCommandPalette">
<Border Width="420" HorizontalAlignment="Center" VerticalAlignment="Center" Effect="drop-shadow(0 0 12 #A0000000)">
<Border Background="{DynamicResource Brush.Popup}" CornerRadius="8">
<ContentControl Margin="16,10,16,12" Content="{Binding CommandPalette}">

View File

@@ -189,6 +189,13 @@ namespace SourceGit.Views
}
}
if (vm.CommandPalette != null)
{
if (e.Key == Key.Escape)
vm.CommandPalette = null;
return;
}
if (e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
{
if (e.Key == Key.W)
@@ -395,23 +402,6 @@ namespace SourceGit.Views
e.Handled = true;
}
private void OnCommandPaletteKeyDown(object sender, KeyEventArgs e)
{
if (DataContext is ViewModels.Launcher { CommandPalette: { } } vm)
{
if (e.Key == Key.Escape)
vm.CommandPalette = null;
e.Route = RoutingStrategies.Direct;
e.Handled = true;
}
}
private void OnCommandPaletteKeyUp(object sender, KeyEventArgs e)
{
e.Handled = true;
}
private WindowState _lastWindowState = WindowState.Normal;
}
}