Browse Source

Fix tooltip hit test following a dirtyRect invalidation not respecting IsHitTestVisible (#19642)

HitTester sees visuals with IsHitTestVisible=false unless you specifically filter them out! Added XML doc warning.
release/11.3.7
Tom Edwards 5 months ago
committed by Julien Lebosquain
parent
commit
3bcab0ecc1
  1. 11
      src/Avalonia.Base/Rendering/IRenderer.cs
  2. 2
      src/Avalonia.Controls/TopLevel.cs

11
src/Avalonia.Base/Rendering/IRenderer.cs

@ -80,6 +80,10 @@ namespace Avalonia.Rendering
/// <summary>
/// Hit tests a location to find the visuals at the specified point.
/// </summary>
/// <remarks>
/// <para>⚠️ This method is low-level and <b>DOES NOT respect <see cref="Input.InputElement.IsHitTestVisible"/></b>.</para>
/// <para>Use <see cref="Input.InputExtensions"/> to perform input hit testing, or provide your own <paramref name="filter"/> function.</para>
/// </remarks>
/// <param name="p">The point, in client coordinates.</param>
/// <param name="root">The root of the subtree to search.</param>
/// <param name="filter">
@ -92,12 +96,7 @@ namespace Avalonia.Rendering
/// <summary>
/// Hit tests a location to find first visual at the specified point.
/// </summary>
/// <param name="p">The point, in client coordinates.</param>
/// <param name="root">The root of the subtree to search.</param>
/// <param name="filter">
/// A filter predicate. If the predicate returns false then the visual and all its
/// children will be excluded from the results.
/// </param>
/// <inheritdoc cref="HitTest(Point, Visual, Func{Visual, bool}?)"/>
/// <returns>The visual at the specified point, topmost first.</returns>
Visual? HitTestFirst(Point p, Visual root, Func<Visual, bool>? filter);
}

2
src/Avalonia.Controls/TopLevel.cs

@ -951,7 +951,7 @@ namespace Avalonia.Controls
var clientPoint = this.PointToClient(lastPos);
if (dirtyRect.Contains(clientPoint))
{
_tooltipService.Update(this, HitTester.HitTestFirst(clientPoint, this, null));
_tooltipService.Update(this, this.InputHitTest(clientPoint, enabledElementsOnly: false) as Visual);
}
}
}

Loading…
Cancel
Save