|
@@ -449,11 +449,16 @@ class _SelectionHandleDriverState extends State<SelectionHandleDriver>
|
449
|
449
|
alignment: Alignment.topLeft,
|
450
|
450
|
width: interactiveRect.width,
|
451
|
451
|
height: interactiveRect.height,
|
452
|
|
- child: GestureDetector(
|
|
452
|
+ child: RawGestureDetector(
|
453
|
453
|
behavior: HitTestBehavior.translucent,
|
454
|
|
- dragStartBehavior: DragStartBehavior.start,
|
455
|
|
- onPanStart: _handleDragStart,
|
456
|
|
- onPanUpdate: _handleDragUpdate,
|
|
454
|
+ gestures: <Type, GestureRecognizerFactory>{
|
|
455
|
+ CustomPanGestureRecognizer: GestureRecognizerFactoryWithHandlers<
|
|
456
|
+ CustomPanGestureRecognizer>(
|
|
457
|
+ () => CustomPanGestureRecognizer(
|
|
458
|
+ onPanDown: _handleDragStart, onPanUpdate: _handleDragUpdate),
|
|
459
|
+ (CustomPanGestureRecognizer instance) {},
|
|
460
|
+ ),
|
|
461
|
+ },
|
457
|
462
|
child: Padding(
|
458
|
463
|
padding: EdgeInsets.only(
|
459
|
464
|
left: padding.left,
|
|
@@ -503,12 +508,13 @@ class _SelectionHandleDriverState extends State<SelectionHandleDriver>
|
503
|
508
|
}
|
504
|
509
|
}
|
505
|
510
|
|
506
|
|
- void _handleDragStart(DragStartDetails details) {
|
507
|
|
- _dragPosition = details.globalPosition;
|
|
511
|
+ bool _handleDragStart(Offset details) {
|
|
512
|
+ _dragPosition = Offset(details.dx, details.dy);
|
|
513
|
+ return true;
|
508
|
514
|
}
|
509
|
515
|
|
510
|
|
- void _handleDragUpdate(DragUpdateDetails details) {
|
511
|
|
- _dragPosition += details.delta;
|
|
516
|
+ void _handleDragUpdate(Offset details) {
|
|
517
|
+ _dragPosition = Offset(details.dx, details.dy);
|
512
|
518
|
final globalPoint = _dragPosition;
|
513
|
519
|
final paragraph = _scope.renderContext.boxForGlobalPoint(globalPoint);
|
514
|
520
|
if (paragraph == null) {
|
|
@@ -606,3 +612,39 @@ class _SelectionToolbarState extends State<_SelectionToolbar> {
|
606
|
612
|
);
|
607
|
613
|
}
|
608
|
614
|
}
|
|
615
|
+
|
|
616
|
+class CustomPanGestureRecognizer extends OneSequenceGestureRecognizer {
|
|
617
|
+ final Function onPanDown;
|
|
618
|
+ final Function onPanUpdate;
|
|
619
|
+
|
|
620
|
+ CustomPanGestureRecognizer({
|
|
621
|
+ @required this.onPanDown,
|
|
622
|
+ @required this.onPanUpdate,
|
|
623
|
+ });
|
|
624
|
+
|
|
625
|
+ @override
|
|
626
|
+ void addPointer(PointerEvent event) {
|
|
627
|
+ if (onPanDown(event.position)) {
|
|
628
|
+ startTrackingPointer(event.pointer);
|
|
629
|
+ resolve(GestureDisposition.accepted);
|
|
630
|
+ } else {
|
|
631
|
+ stopTrackingPointer(event.pointer);
|
|
632
|
+ }
|
|
633
|
+ }
|
|
634
|
+
|
|
635
|
+ @override
|
|
636
|
+ void handleEvent(PointerEvent event) {
|
|
637
|
+ if (event is PointerMoveEvent) {
|
|
638
|
+ onPanUpdate(event.position);
|
|
639
|
+ }
|
|
640
|
+ if (event is PointerUpEvent) {
|
|
641
|
+ stopTrackingPointer(event.pointer);
|
|
642
|
+ }
|
|
643
|
+ }
|
|
644
|
+
|
|
645
|
+ @override
|
|
646
|
+ String get debugDescription => 'customPan';
|
|
647
|
+
|
|
648
|
+ @override
|
|
649
|
+ void didStopTrackingLastPointer(int pointer) {}
|
|
650
|
+}
|