Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom hit testing #5968

Merged
merged 7 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Avalonia.Controls/Primitives/LightDismissOverlayLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public bool HitTest(Point point)
{
if (InputPassThroughElement is object)
{
var p = point.Transform(this.TransformToVisual(VisualRoot)!.Value);
var hit = VisualRoot.GetVisualAt(p, x => x != this);
var hit = VisualRoot.GetVisualAt(point, x => x != this);

if (hit is object)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Visuals/Rendering/ICustomSimpleHitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface ICustomHitTest : ICustomSimpleHitTest
public static class CustomSimpleHitTestExtensions
{
public static bool HitTestCustom(this IVisual visual, Point point)
=> (visual as ICustomSimpleHitTest)?.HitTest(point) ?? visual.TransformedBounds?.Contains(point) == true;
=> (visual as ICustomSimpleHitTest)?.HitTest(point) ?? false;
wieslawsoltes marked this conversation as resolved.
Show resolved Hide resolved

public static bool HitTestCustom(this IEnumerable<IVisual> children, Point point)
=> children.Any(ctrl => ctrl.HitTestCustom(point));
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Visuals/Rendering/SceneGraph/Scene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private bool FilterAndClip(IVisualNode node, ref Rect? clip)
clipped = !node.GeometryClip.FillContains(controlPoint.Value);
}

if (!clipped && node.Visual is ICustomHitTest custom)
if (!clipped && node.Visual is ICustomSimpleHitTest custom)
wieslawsoltes marked this conversation as resolved.
Show resolved Hide resolved
{
clipped = !custom.HitTest(_point);
}
Expand Down