Browse Source

Use logical tree to detect if we're in a menu.

Visual tree does not work when using overlay popups because the popups are displayed as visual children of the overlay layer. This is not a problem for native popups as each popup has its own `AccessKeyHandler`.
pull/10461/head
Steven Kirk 4 years ago
parent
commit
034064a45f
  1. 5
      src/Avalonia.Base/Input/AccessKeyHandler.cs

5
src/Avalonia.Base/Input/AccessKeyHandler.cs

@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Avalonia.Interactivity;
using Avalonia.VisualTree;
using Avalonia.LogicalTree;
namespace Avalonia.Input
{
@ -190,7 +189,7 @@ namespace Avalonia.Input
// If the menu is open, only match controls in the menu's visual tree.
if (menuIsOpen)
{
matches = matches.Where(x => x is not null && ((Visual)MainMenu!).IsVisualAncestorOf((Visual)x));
matches = matches.Where(x => x is not null && ((Visual)MainMenu!).IsLogicalAncestorOf((Visual)x));
}
var match = matches.FirstOrDefault();

Loading…
Cancel
Save