Fix item hitbox ignoring transparency - #25
Merged
Conversation
Replace the pointer-event filter approach with a proper HitTestCore override so transparent pixels fail Avalonia's visual hit-test walk. When HitTestCore returns false, Avalonia continues searching elements below in z-order, allowing clicks on transparent areas to fall through to the item underneath. The previous OnPointerPressed/Moved/Released filtering still consumed the event even on transparent pixels, preventing sibling elements at lower z-order from receiving it. Fixes #8 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PointHitTestParameters does not exist in Avalonia — it is a WPF type. The correct Avalonia 11 API for per-pixel hit testing is implementing the ICustomHitTest interface (Avalonia.Rendering), whose HitTest(Point) method is called by the compositor instead of the default bounding-box check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
InputMaskingImagewas using pointer-event filtering (OnPointerPressedetc.) to suppress clicks on transparent pixels, but this approach doesn't work for items stacked in z-order. Avalonia's hit-test walk picks the front-most element that passesHitTestCore(which defaulted to the full bounding box), routes the event there, and stops — so the transparent area of one item would consume clicks intended for the item below it.Fix: Replace the event-filter approach with a proper
HitTestCoreoverride. WhenHitTestCorereturnsfalse, Avalonia continues its hit-test walk to the next element in z-order, so transparent pixels cleanly pass through to whatever is beneath them.Test plan
Closes #8
🤖 Generated with Claude Code