public TextSelectionGestureDetector( Key key = null, GestureTapDownCallback onTapDown = null, GestureForcePressStartCallback onForcePressStart = null, GestureForcePressEndCallback onForcePressEnd = null, GestureTapUpCallback onSingleTapUp = null, GestureTapCancelCallback onSingleTapCancel = null, GestureLongPressStartCallback onSingleLongTapStart = null, GestureLongPressMoveUpdateCallback onSingleLongTapMoveUpdate = null, GestureLongPressEndCallback onSingleLongTapEnd = null, GestureTapDownCallback onDoubleTapDown = null, GestureDragStartCallback onDragSelectionStart = null, DragSelectionUpdateCallback onDragSelectionUpdate = null, GestureDragEndCallback onDragSelectionEnd = null, HitTestBehavior?behavior = null, Widget child = null ) : base(key: key) { D.assert(child != null); this.onTapDown = onTapDown; this.onForcePressEnd = onForcePressEnd; this.onForcePressStart = onForcePressStart; this.onSingleTapUp = onSingleTapUp; this.onSingleTapCancel = onSingleTapCancel; this.onSingleLongTapStart = onSingleLongTapStart; this.onDoubleTapDown = onDoubleTapDown; this.onDragSelectionStart = onDragSelectionStart; this.onDragSelectionUpdate = onDragSelectionUpdate; this.onDragSelectionEnd = onDragSelectionEnd; this.behavior = behavior; this.child = child; }
public override Widget build(BuildContext context) { Dictionary <Type, GestureRecognizerFactory> gestures = new Dictionary <Type, GestureRecognizerFactory>(); gestures.Add(typeof(_TransparentTapGestureRecognizer), new GestureRecognizerFactoryWithHandlers <_TransparentTapGestureRecognizer>( () => new _TransparentTapGestureRecognizer(debugOwner: this), (_TransparentTapGestureRecognizer instance) => { instance.onTapDown = _handleTapDown; instance.onTapUp = _handleTapUp; instance.onTapCancel = _handleTapCancel; } ) ); if (widget.onSingleLongTapStart != null || widget.onSingleLongTapMoveUpdate != null || widget.onSingleLongTapEnd != null ) { gestures[typeof(LongPressGestureRecognizer)] = new GestureRecognizerFactoryWithHandlers <LongPressGestureRecognizer>( () => new LongPressGestureRecognizer(debugOwner: this, kind: PointerDeviceKind.touch), instance => { instance.onLongPressStart = _handleLongPressStart; instance.onLongPressMoveUpdate = _handleLongPressMoveUpdate; instance.onLongPressEnd = _handleLongPressEnd; }); } if (widget.onDragSelectionStart != null || widget.onDragSelectionUpdate != null || widget.onDragSelectionEnd != null) { gestures.Add(typeof(HorizontalDragGestureRecognizer), new GestureRecognizerFactoryWithHandlers <HorizontalDragGestureRecognizer>( () => new HorizontalDragGestureRecognizer(debugOwner: this, kind: PointerDeviceKind.mouse), instance => { instance.dragStartBehavior = DragStartBehavior.down; instance.onStart = _handleDragStart; instance.onUpdate = _handleDragUpdate; instance.onEnd = _handleDragEnd; } ) ); } if (widget.onForcePressStart != null || widget.onForcePressEnd != null) { GestureForcePressStartCallback startInstance = null; if (widget.onForcePressStart != null) { startInstance = _forcePressStarted; } GestureForcePressEndCallback endInstance = null; if (widget.onForcePressEnd != null) { endInstance = _forcePressEnded; } gestures[typeof(ForcePressGestureRecognizer)] = new GestureRecognizerFactoryWithHandlers <ForcePressGestureRecognizer>( () => new ForcePressGestureRecognizer(debugOwner: this), (ForcePressGestureRecognizer instance) => { instance.onStart = startInstance; instance.onEnd = endInstance; } ); } return(new RawGestureDetector( gestures: gestures, behavior: widget.behavior, child: widget.child )); }
public GestureDetector( Key key = null, Widget child = null, GestureTapDownCallback onTapDown = null, GestureTapUpCallback onTapUp = null, GestureTapCallback onTap = null, GestureTapCancelCallback onTapCancel = null, GestureTapDownCallback onSecondaryTapDown = null, GestureTapUpCallback onSecondaryTapUp = null, GestureTapCancelCallback onSecondaryTapCancel = null, GestureDoubleTapCallback onDoubleTap = null, GestureLongPressCallback onLongPress = null, GestureLongPressStartCallback onLongPressStart = null, GestureLongPressMoveUpdateCallback onLongPressMoveUpdate = null, GestureLongPressUpCallback onLongPressUp = null, GestureLongPressEndCallback onLongPressEnd = null, GestureDragDownCallback onVerticalDragDown = null, GestureDragStartCallback onVerticalDragStart = null, GestureDragUpdateCallback onVerticalDragUpdate = null, GestureDragEndCallback onVerticalDragEnd = null, GestureDragCancelCallback onVerticalDragCancel = null, GestureDragDownCallback onHorizontalDragDown = null, GestureDragStartCallback onHorizontalDragStart = null, GestureDragUpdateCallback onHorizontalDragUpdate = null, GestureDragEndCallback onHorizontalDragEnd = null, GestureDragCancelCallback onHorizontalDragCancel = null, GestureForcePressStartCallback onForcePressStart = null, GestureForcePressPeakCallback onForcePressPeak = null, GestureForcePressUpdateCallback onForcePressUpdate = null, GestureForcePressEndCallback onForcePressEnd = null, GestureDragDownCallback onPanDown = null, GestureDragStartCallback onPanStart = null, GestureDragUpdateCallback onPanUpdate = null, GestureDragEndCallback onPanEnd = null, GestureDragCancelCallback onPanCancel = null, GestureScaleStartCallback onScaleStart = null, GestureScaleUpdateCallback onScaleUpdate = null, GestureScaleEndCallback onScaleEnd = null, HitTestBehavior behavior = HitTestBehavior.deferToChild, DragStartBehavior dragStartBehavior = DragStartBehavior.down ) : base(key) { D.assert(() => { bool haveVerticalDrag = onVerticalDragStart != null || onVerticalDragUpdate != null || onVerticalDragEnd != null; bool haveHorizontalDrag = onHorizontalDragStart != null || onHorizontalDragUpdate != null || onHorizontalDragEnd != null; bool havePan = onPanStart != null || onPanUpdate != null || onPanEnd != null; bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null; if (havePan || haveScale) { if (havePan && haveScale) { throw new UIWidgetsError(new List <DiagnosticsNode> { new ErrorSummary("Incorrect GestureDetector arguments."), new ErrorDescription( "Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan." ), new ErrorHint("Just use the scale gesture recognizer.") }); } string recognizer = havePan ? "pan" : "scale"; if (haveVerticalDrag && haveHorizontalDrag) { throw new UIWidgetsError( "Incorrect GestureDetector arguments.\n" + $"Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a {recognizer} gesture recognizer " + $"will result in the {recognizer} gesture recognizer being ignored, since the other two will catch all drags." ); } } return(true); }); this.child = child; this.onTapDown = onTapDown; this.onTapUp = onTapUp; this.onTap = onTap; this.onTapCancel = onTapCancel; this.onSecondaryTapDown = onSecondaryTapDown; this.onSecondaryTapUp = onSecondaryTapUp; this.onSecondaryTapCancel = onSecondaryTapCancel; this.onDoubleTap = onDoubleTap; this.onLongPress = onLongPress; this.onLongPressUp = onLongPressUp; this.onLongPressStart = onLongPressStart; this.onLongPressMoveUpdate = onLongPressMoveUpdate; this.onLongPressEnd = onLongPressEnd; this.onVerticalDragDown = onVerticalDragDown; this.onVerticalDragStart = onVerticalDragStart; this.onVerticalDragUpdate = onVerticalDragUpdate; this.onVerticalDragEnd = onVerticalDragEnd; this.onVerticalDragCancel = onVerticalDragCancel; this.onHorizontalDragDown = onHorizontalDragDown; this.onHorizontalDragStart = onHorizontalDragStart; this.onHorizontalDragUpdate = onHorizontalDragUpdate; this.onHorizontalDragEnd = onHorizontalDragEnd; this.onHorizontalDragCancel = onHorizontalDragCancel; this.onForcePressEnd = onForcePressEnd; this.onForcePressPeak = onForcePressPeak; this.onForcePressStart = onForcePressStart; this.onForcePressUpdate = onForcePressUpdate; this.onPanDown = onPanDown; this.onPanStart = onPanStart; this.onPanUpdate = onPanUpdate; this.onPanEnd = onPanEnd; this.onPanCancel = onPanCancel; this.onScaleStart = onScaleStart; this.onScaleUpdate = onScaleUpdate; this.onScaleEnd = onScaleEnd; this.behavior = behavior; this.dragStartBehavior = dragStartBehavior; }