hitTest method

  1. @override
GDisplayObject? hitTest(
  1. GPoint localPoint, [
  2. bool useShape = false
])
override

Returns the deepest GDisplayObject that lies under the given point.

The localPoint parameter is the point to check for an object under it.

The useShape parameter is not used in this implementation.

Returns the GDisplayObject that lies under the given point or null if there is no such object.

Implementation

@override
GDisplayObject? hitTest(GPoint localPoint, [bool useShape = false]) {
  if (!visible || !mouseEnabled) {
    return null;
  }

  /// location outside stage area, is not accepted.
  if (localPoint.x < 0 ||
      localPoint.x > stageWidth ||
      localPoint.y < 0 ||
      localPoint.y > stageHeight) {
    return null;
  }

  /// if nothing is hit, stage returns itself as target.
  return super.hitTest(localPoint) ?? this;
}