Unverified Commit bef3512d authored by Gary Qian's avatar Gary Qian Committed by GitHub

DoubleTap recognizer support and improved error message (#56328)

parent 2f04ba91
......@@ -916,10 +916,13 @@ class RenderParagraph extends RenderBox
if (recognizer is TapGestureRecognizer) {
configuration.onTap = recognizer.onTap;
configuration.isLink = true;
} else if (recognizer is DoubleTapGestureRecognizer) {
configuration.onTap = recognizer.onDoubleTap;
configuration.isLink = true;
} else if (recognizer is LongPressGestureRecognizer) {
configuration.onLongPress = recognizer.onLongPress;
} else {
assert(false);
assert(false, '${recognizer.runtimeType} is not supported.');
}
}
final SemanticsNode newChild = (_cachedChildNodes?.isNotEmpty == true)
......
......@@ -417,4 +417,37 @@ void main() {
expect(boxes[8], const TextBox.fromLTRBD(14.0, 28.0, 28.0, 42.0 , TextDirection.ltr));
// Ahem-based tests don't yet quite work on Windows or some MacOS environments
}, skip: isWindows || isMacOS || isBrowser);
test('Supports gesture recognizer semantics', () {
final RenderParagraph paragraph = RenderParagraph(
TextSpan(text: _kText, children: <InlineSpan>[
TextSpan(text: 'one', recognizer: TapGestureRecognizer()..onTap = () {}),
TextSpan(text: 'two', recognizer: LongPressGestureRecognizer()..onLongPress = () {}),
TextSpan(text: 'three', recognizer: DoubleTapGestureRecognizer()..onDoubleTap = () {}),
]),
textDirection: TextDirection.rtl,
);
layout(paragraph);
paragraph.assembleSemanticsNode(SemanticsNode(), SemanticsConfiguration(), <SemanticsNode>[]);
});
test('Asserts on unsupported gesture recognizer', () {
final RenderParagraph paragraph = RenderParagraph(
TextSpan(text: _kText, children: <InlineSpan>[
TextSpan(text: 'three', recognizer: MultiTapGestureRecognizer()..onTap = (int id) {}),
]),
textDirection: TextDirection.rtl,
);
layout(paragraph);
bool failed = false;
try {
paragraph.assembleSemanticsNode(SemanticsNode(), SemanticsConfiguration(), <SemanticsNode>[]);
} catch(e) {
failed = true;
expect(e.message, 'MultiTapGestureRecognizer is not supported.');
}
expect(failed, true);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment