The code change allows to override the default behaviour of clicking on
images and thus solves #90
An error occurred
.
Now the only thing left to do is to use a `RawGestureDetector` in the
`EmbedBuilder` to deactivate the "old" behaviour (by entering the
GestureArena and win). The `embedBuilder` could look like this:
```dart
Widget embedBuilder(BuildContext context, Embed node, bool readOnly) {
return FutureBuilder<File>(
future: File('image_path.png'),
builder: (context, snapshot) {
final gestures = {
ReadDependentGestureRecognizer: GestureRecognizerFactoryWithHandlers<
ReadDependentGestureRecognizer>(
() => ReadDependentGestureRecognizer(readOnly: readOnly),
(instance) => instance
..onTapUp = ((_) => print('Test'))
)
};
return RawGestureDetector(
gestures: gestures,
child: Image.file(snapshot.data),
);
}
);
}
class ReadDependentGestureRecognizer extends TapGestureRecognizer {
ReadDependentGestureRecognizer({@required this.readOnly});
final bool readOnly;
@override
bool isPointerAllowed(PointerDownEvent event) {
if (!readOnly) {
return false;
}
return super.isPointerAllowed(event);
}
}
```
**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, `false` was always returned, 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.
Additionally I removed the class `_TransparentTapGestureRecognizer`,
because this class always accepted the gesture, even if the recognizer
lost in the arena.