hitTest method
Determines if the point specified by localPoint
is contained within this
GSprite. If useShape
is true, the shape of the GSprite will be used
to test for containment. Otherwise, the bounds of the GSprite will be
used.
The localPoint
parameter is a GPoint object representing the point to
test for containment, in the local coordinate space of this GSprite.
The useShape
parameter is an optional boolean value that determines
whether to use the shape of the GSprite or the bounds of the GSprite
to test for containment. If it is not specified, it will default to false.
Returns the GDisplayObject that contains the point, or null if the point is not contained within this GSprite.
Implementation
@override
GDisplayObject? hitTest(GPoint localPoint, [bool useShape = false]) {
if (!visible || !mouseEnabled) {
return null;
}
var target = super.hitTest(localPoint);
target ??=
(_graphics?.hitTest(localPoint, useShape) ?? false) ? this : null;
return target;
}