예제 #1
0
        protected override bool hitTestChildren(
            BoxHitTestResult result,
            Offset position = null
            )
        {
            D.assert(_paintTransform != null || debugNeedsLayout || child == null);
            if (child == null || _paintTransform == null)
            {
                return(false);
            }

            return(result.addWithPaintTransform(
                       transform: _paintTransform,
                       position: position,
                       hitTest: (BoxHitTestResult resultIn, Offset positionIn) => {
                return child.hitTest(resultIn, position: positionIn);
            }
                       ));
        }
예제 #2
0
        protected override bool hitTestChildren(BoxHitTestResult boxHitTestResult, Offset position = null)
        {
            RenderBox child = firstChild;

            while (child != null)
            {
                TextParentData textParentData = child.parentData as TextParentData;
                Matrix4        transform      = Matrix4.translationValues(
                    textParentData.offset.dx,
                    textParentData.offset.dy,
                    0.0f
                    );
                transform.scale(
                    textParentData.scale,
                    textParentData.scale,
                    textParentData.scale
                    );
                bool isHit = boxHitTestResult.addWithPaintTransform(
                    transform: transform,
                    position: position,
                    hitTest: (BoxHitTestResult result, Offset transformed) => {
                    D.assert(() => {
                        Offset manualPosition = (position - textParentData.offset) / textParentData.scale;
                        return((transformed.dx - manualPosition.dx).abs() < foundation_.precisionErrorTolerance &&
                               (transformed.dy - manualPosition.dy).abs() < foundation_.precisionErrorTolerance);
                    });
                    return(child.hitTest(result, position: transformed));
                }
                    );
                if (isHit)
                {
                    return(true);
                }
                child = childAfter(child);
            }
            return(false);
        }