DoubleTap recognizer support and improved error message (#56328)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user