code_style: simplify the way detacting system preferred command key

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-06 10:36:10 +08:00
parent d50b2c0298
commit c72506d939
No known key found for this signature in database
3 changed files with 3 additions and 6 deletions

View file

@ -125,7 +125,7 @@ namespace SourceGit.Views
DescriptionEditor.CaretIndex = 0; DescriptionEditor.CaretIndex = 0;
e.Handled = true; e.Handled = true;
} }
else if (e.Key == Key.V && ((OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Meta) || (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control))) else if (e.Key == Key.V && e.KeyModifiers == (OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
{ {
e.Handled = true; e.Handled = true;

View file

@ -722,9 +722,7 @@ namespace SourceGit.Views
private void OnCommitListKeyDown(object sender, KeyEventArgs e) private void OnCommitListKeyDown(object sender, KeyEventArgs e)
{ {
bool isSystemCmdKeyDown = (OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Meta)) || if (!e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
(!OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Control));
if (!isSystemCmdKeyDown)
return; return;
// These shortcuts are not mentioned in the Shortcut Reference window. Is this expected? // These shortcuts are not mentioned in the Shortcut Reference window. Is this expected?

View file

@ -115,8 +115,7 @@ namespace SourceGit.Views
return; return;
} }
if ((OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Meta)) || if (e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
(!OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Control)))
{ {
if (e.Key == Key.W) if (e.Key == Key.W)
{ {