onSingleLongTapMoveUpdate method

  1. @protected
void onSingleLongTapMoveUpdate(
  1. LongPressMoveUpdateDetails details
)

Handler for TextSelectionGestureDetector.onSingleLongTapMoveUpdate.

By default, it updates the selection location specified in details if selection is enabled.

See also:

Implementation

@protected
void onSingleLongTapMoveUpdate(LongPressMoveUpdateDetails details) {
  if (delegate.selectionEnabled) {
    // Adjust the drag start offset for possible viewport offset changes.
    final Offset editableOffset = renderEditable.maxLines == 1
        ? Offset(renderEditable.offset.pixels - _dragStartViewportOffset, 0.0)
        : Offset(0.0, renderEditable.offset.pixels - _dragStartViewportOffset);
    final Offset scrollableOffset = Offset(
      0.0,
      _scrollPosition - _dragStartScrollOffset,
    );
    switch (defaultTargetPlatform) {
      case TargetPlatform.iOS:
      case TargetPlatform.macOS:
        if (_longPressStartedWithoutFocus) {
          renderEditable.selectWordsInRange(
            from: details.globalPosition - details.offsetFromOrigin - editableOffset - scrollableOffset,
            to: details.globalPosition,
            cause: SelectionChangedCause.longPress,
          );
        } else {
          renderEditable.selectPositionAt(
            from: details.globalPosition,
            cause: SelectionChangedCause.longPress,
          );
          // Update the floating cursor.
          final RawFloatingCursorPoint cursorPoint = RawFloatingCursorPoint(
            state: FloatingCursorDragState.Update,
            offset: details.offsetFromOrigin,
          );
          editableText.updateFloatingCursor(cursorPoint);
        }
      case TargetPlatform.android:
      case TargetPlatform.fuchsia:
      case TargetPlatform.linux:
      case TargetPlatform.windows:
        renderEditable.selectWordsInRange(
          from: details.globalPosition - details.offsetFromOrigin - editableOffset - scrollableOffset,
          to: details.globalPosition,
          cause: SelectionChangedCause.longPress,
        );
    }

    _showMagnifierIfSupportedByPlatform(details.globalPosition);
  }
}