public override DisplayObject HitTest(Vector2 localPoint, bool forTouch)
{
if (_skipRendering)
{
return(null);
}
if (forTouch && (!visible || !touchable || optimizeNotTouchable))
{
return(null);
}
if (_clipRect != null && !((Rect)_clipRect).Contains(localPoint))
{
return(null);
}
else
{
int count = _children.Count;
DisplayObject target = null;
for (int i = count - 1; i >= 0; --i) // front to back!
{
DisplayObject child = _children[i];
Vector2 v = TransformPoint(localPoint, child);
target = child.HitTest(v, forTouch);
if (target != null)
{
break;
}
}
if (target == null && _hitArea != null)
{
if (((Rect)_hitArea).Contains(localPoint))
{
target = this;
}
}
return(target);
}
}