Browse Source

Dont focus menu then alt key down event is followed

by another keydown event.
pull/765/head
Dan Walmsley 10 years ago
parent
commit
4c5c099ec3
  1. 13
      src/Avalonia.Input/AccessKeyHandler.cs

13
src/Avalonia.Input/AccessKeyHandler.cs

@ -43,6 +43,11 @@ namespace Avalonia.Input
/// </summary>
private bool _ignoreAltUp;
/// <summary>
/// Whether the AltKey is down.
/// </summary>
private bool _altIsDown;
/// <summary>
/// Gets or sets the window's main menu.
/// </summary>
@ -110,6 +115,8 @@ namespace Avalonia.Input
{
if (e.Key == Key.LeftAlt)
{
_altIsDown = true;
if (MainMenu == null || !MainMenu.IsOpen)
{
// When Alt is pressed without a main menu, or with a closed main menu, show
@ -126,6 +133,10 @@ namespace Avalonia.Input
// We always handle the Alt key.
e.Handled = true;
}
else if(_altIsDown)
{
_ignoreAltUp = true;
}
}
/// <summary>
@ -179,6 +190,8 @@ namespace Avalonia.Input
switch (e.Key)
{
case Key.LeftAlt:
_altIsDown = false;
if (_ignoreAltUp)
{
_ignoreAltUp = false;

Loading…
Cancel
Save