vector_graphics icon indicating copy to clipboard operation
vector_graphics copied to clipboard

Ignore hits on transparent parts of the image

Open bramp opened this issue 2 years ago • 2 comments

It seems the entire rectangle of the RenderVectorGraphic absorbs hits (for example when a user taps the screen).

Would it be possible to adjust the hitTestSelf to only return true if the hit is on a non-transparent part of the SVG?

bramp avatar Oct 10 '23 20:10 bramp

That would be expensive and probably not quite the desired behavior in a lot of cases.

Imagine, for example, you have an icon you're painting on a button - you don't want to do expensive hit testing logic to see if the hit falls within some complicated path describing the outline of the icon just to end up getting a hit on the button "under" it...

dnfield avatar Oct 10 '23 20:10 dnfield

Oh absolutely, it's not desirable for every use case. Maybe I should have framed it as "Could you make it optional" to ignore hits in the transparent parts of the SVG.

In my use case, I have a circular button drawn as a SVG, and with the current hit test you can hit outside of the bounds of what's visible, which is undesirable.

I suspect the work around, is for me calculating a mask and implementing my own "hit test" on top of the SVG.

bramp avatar Oct 10 '23 21:10 bramp