Browse Source

Handle default actions to prevent beeping sounds

pull/6991/head
Lubomir Tetak 4 years ago
parent
commit
11c1543b5a
  1. 3
      samples/ControlCatalog/Pages/DialogsPage.xaml.cs
  2. 2
      src/Avalonia.Controls/Button.cs

3
samples/ControlCatalog/Pages/DialogsPage.xaml.cs

@ -128,7 +128,8 @@ namespace ControlCatalog.Pages
(button = new Button (button = new Button
{ {
HorizontalAlignment = HorizontalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center,
Content = "Click to close" Content = "Click to close",
IsDefault = true
}) })
} }
}, },

2
src/Avalonia.Controls/Button.cs

@ -547,6 +547,7 @@ namespace Avalonia.Controls
if (e.Key == Key.Enter && IsVisible && IsEnabled) if (e.Key == Key.Enter && IsVisible && IsEnabled)
{ {
OnClick(); OnClick();
e.Handled = true;
} }
} }
@ -560,6 +561,7 @@ namespace Avalonia.Controls
if (e.Key == Key.Escape && IsVisible && IsEnabled) if (e.Key == Key.Escape && IsVisible && IsEnabled)
{ {
OnClick(); OnClick();
e.Handled = true;
} }
} }

Loading…
Cancel
Save