Skip to content

Commit

Permalink
Merge pull request #6991 from ltetak/osx_sound_defaultactions
Browse files Browse the repository at this point in the history
[OSX] Handle default dialog actions to prevent beeping sounds
  • Loading branch information
maxkatz6 authored and danwalmsley committed May 10, 2022
1 parent 2980e94 commit 60ebbb7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion samples/ControlCatalog/Pages/DialogsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ private Window CreateSampleWindow()
(button = new Button
{
HorizontalAlignment = HorizontalAlignment.Center,
Content = "Click to close"
Content = "Click to close",
IsDefault = true
})
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/Avalonia.Controls/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ private void RootDefaultKeyDown(object sender, KeyEventArgs e)
if (e.Key == Key.Enter && IsVisible && IsEnabled)
{
OnClick();
e.Handled = true;
}
}

Expand All @@ -563,6 +564,7 @@ private void RootCancelKeyDown(object sender, KeyEventArgs e)
if (e.Key == Key.Escape && IsVisible && IsEnabled)
{
OnClick();
e.Handled = true;
}
}

Expand Down

0 comments on commit 60ebbb7

Please sign in to comment.