微信交流群

老孟公众号

# TextSelectionGestureDetector

TextSelectionGestureDetector 是一个文本选择的手势识别控件,和GestureDetector的区别是GestureDetector只能处理单击或者双击事件,而TextSelectionGestureDetector可以同时处理单击和双击事件。

TextSelectionGestureDetector(
  child: SelectableText('TextSelectionGestureDetector'),
  onTapDown: (TapDownDetails details) {
    print('onTapDown');
  },
)
1
2
3
4
5
6

onTapDown:单击事件

TextSelectionGestureDetector(
  child: SelectableText('TextSelectionGestureDetector'),
  onTapDown: (TapDownDetails details) {
    print('onTapDown');
  },
  onSingleTapUp: (TapUpDetails details) {
    print('onSingleTapUp');
  },
  onSingleTapCancel: () {
    print('onSingleTapCancel');
  },
  onSingleLongTapStart: (LongPressStartDetails details) {
    print('onSingleLongTapStart');
  },
  onSingleLongTapMoveUpdate: (LongPressMoveUpdateDetails details) {
    print('onSingleLongTapMoveUpdate');
  },
  onSingleLongTapEnd: (LongPressEndDetails details) {
    print('onSingleLongTapEnd');
  },
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

onSingleTapUp:单击抬起事件

onSingleTapCancel:单击取消事件

onSingleLongTapStart:长按开始事件

onSingleLongTapMoveUpdate:长按移动事件

onSingleLongTapEnd:长按结束事件

TextSelectionGestureDetector(
  child: SelectableText('TextSelectionGestureDetector'),
  onDoubleTapDown: (TapDownDetails details) {
    print('onDoubleTapDown');
  },
)
1
2
3
4
5
6

onDoubleTapDown:双击事件