enhance: clear unhandled key modifer before running command (#748)
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions
Localization Check / localization-check (push) Waiting to run

This commit is contained in:
leo 2024-11-27 20:21:01 +08:00
parent 1872148d98
commit e224f59ea7
No known key found for this signature in database
2 changed files with 18 additions and 2 deletions

View file

@ -72,6 +72,11 @@ namespace SourceGit.Views
return _unhandledModifiers.HasFlag(modifier);
}
public void ClearKeyModifier()
{
_unhandledModifiers = KeyModifiers.None;
}
protected override void OnOpened(EventArgs e)
{
base.OnOpened(e);

View file

@ -53,6 +53,7 @@ namespace SourceGit.Views
if (!startDirectly && OperatingSystem.IsMacOS())
startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta);
launcher.ClearKeyModifier();
repo.Fetch(startDirectly);
e.Handled = true;
}
@ -67,6 +68,7 @@ namespace SourceGit.Views
if (!startDirectly && OperatingSystem.IsMacOS())
startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta);
launcher.ClearKeyModifier();
repo.Pull(startDirectly);
e.Handled = true;
}
@ -81,6 +83,7 @@ namespace SourceGit.Views
if (!startDirectly && OperatingSystem.IsMacOS())
startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta);
launcher.ClearKeyModifier();
repo.Push(startDirectly);
e.Handled = true;
}
@ -89,8 +92,16 @@ namespace SourceGit.Views
private void StashAll(object _, RoutedEventArgs e)
{
var launcher = this.FindAncestorOfType<Launcher>();
(DataContext as ViewModels.Repository)?.StashAll(launcher?.HasKeyModifier(KeyModifiers.Control) ?? false);
e.Handled = true;
if (launcher is not null && DataContext is ViewModels.Repository repo)
{
var startDirectly = launcher.HasKeyModifier(KeyModifiers.Control);
if (!startDirectly && OperatingSystem.IsMacOS())
startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta);
launcher.ClearKeyModifier();
repo.StashAll(startDirectly);
e.Handled = true;
}
}
private void OpenGitFlowMenu(object sender, RoutedEventArgs e)