hitTest method
Determines if the point specified by localPoint
is contained within this
GShape. If useShape
is true, the shape of the GShape will be used to
test for containment. Otherwise, the bounds of the GShape will be used.
The localPoint
parameter is a GPoint object representing the point to
test for containment, in the local coordinate space of this GShape.
The useShape
parameter is an optional boolean value that determines
whether to use the shape of the GShape or the bounds of the GShape 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 GShape.
Implementation
@override
GDisplayObject? hitTest(GPoint localPoint, [bool useShape = false]) {
if (!$hasTouchableArea || !mouseEnabled) {
return null;
}
if (($mask != null || maskRect != null) && !hitTestMask(localPoint)) {
return null;
}
return (_graphics?.hitTest(localPoint, useShape) ?? false) ? this : null;
}