Browse Source

fix immediate rendering hit testing for AdornerLayer

pull/3357/head
Andrey Kunchev 7 years ago
parent
commit
36dd50e645
  1. 5
      src/Avalonia.Controls/Primitives/AdornerLayer.cs
  2. 13
      src/Avalonia.Visuals/Rendering/ICustomSimpleHitTest.cs

5
src/Avalonia.Controls/Primitives/AdornerLayer.cs

@ -138,10 +138,7 @@ namespace Avalonia.Controls.Primitives
} }
} }
public bool HitTest(Point point) public bool HitTest(Point point) => Children.HitTestCustom(point);
{
return Children.Any(ctrl => ctrl.TransformedBounds?.Contains(point) == true);
}
private class AdornedElementInfo private class AdornedElementInfo
{ {

13
src/Avalonia.Visuals/Rendering/ICustomSimpleHitTest.cs

@ -1,3 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Avalonia.VisualTree;
namespace Avalonia.Rendering namespace Avalonia.Rendering
{ {
/// <summary> /// <summary>
@ -9,4 +13,13 @@ namespace Avalonia.Rendering
{ {
bool HitTest(Point point); bool HitTest(Point point);
} }
public static class CustomSimpleHitTestExtensions
{
public static bool HitTestCustom(this IVisual visual, Point point)
=> (visual as ICustomSimpleHitTest)?.HitTest(point) ?? visual.TransformedBounds?.Contains(point) == true;
public static bool HitTestCustom(this IEnumerable<IVisual> children, Point point)
=> children.Any(ctrl => ctrl.HitTestCustom(point));
}
} }

Loading…
Cancel
Save