onTapDown method
Handler for TextSelectionGestureDetector.onTapDown.
By default, it forwards the tap to RenderEditable.handleTapDown and sets shouldShowSelectionToolbar to true if the tap was initiated by a finger or stylus.
See also:
- TextSelectionGestureDetector.onTapDown, which triggers this callback.
Implementation
@protected
void onTapDown(TapDownDetails details) {
renderEditable.handleTapDown(details);
// The selection overlay should only be shown when the user is interacting
// through a touch screen (via either a finger or a stylus). A mouse shouldn't
// trigger the selection overlay.
// For backwards-compatibility, we treat a null kind the same as touch.
final PointerDeviceKind? kind = details.kind;
_shouldShowSelectionToolbar = kind == null ||
kind == PointerDeviceKind.touch ||
kind == PointerDeviceKind.stylus;
// Handle shift + click selection if needed.
final bool isShiftPressed =
HardwareKeyboard.instance.logicalKeysPressed.any(<LogicalKeyboardKey>{
LogicalKeyboardKey.shiftLeft,
LogicalKeyboardKey.shiftRight,
}.contains);
if (isShiftPressed && renderEditable.selection?.baseOffset != null) {
_isShiftTapping = true;
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
_expandSelection(details.globalPosition, SelectionChangedCause.tap);
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
_extendSelection(details.globalPosition, SelectionChangedCause.tap);
break;
}
}
}