Add hitTesting to allow changing click behavior in embeds

This allows us to override the default behavior of clicking on
images and thus solves PR #90. Now the only thing left to do is
to use a RawGestureDetector in the EmbedBuilder to deactivate the
previous behavior (by entering the GestureArena and always win).

Explanation of the code:
When a `PointerDownEvent` is received by the `GestureBinding` a hit
test is performed to determine which HitTestTarget nodes are affected.
For this the (I think) element tree is traversed downwards to find
out which elements has been hit. To find out which elements were
hit, the method `hitTestSelf` and `hitTestChildren` are used. Since
the `hitTestChildren` method of TextLine has not been implemented yet,
it has always returned false by default, which is why the hit test
never arrived at the `embedBuilder`. With the code change, the hit is
passed on and can be processed correctly in the embed.
pull/94/head
Till Friebe 4 years ago
parent e36033929c
commit 01d5fd5669
  1. 5
      lib/widgets/text_line.dart

@ -785,6 +785,11 @@ class RenderEditableTextLine extends RenderEditableBox {
);
_cursorPainter.paint(context.canvas, effectiveOffset, position);
}
@override
bool hitTestChildren(BoxHitTestResult result, {Offset position}) {
return this._children.first.hitTest(result, position: position);
}
}
class _TextLineElement extends RenderObjectElement {

Loading…
Cancel
Save