|
|
@ -690,7 +690,7 @@ class _QuillEditorSelectionGestureDetectorBuilder |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
editor!.hideToolbar(); |
|
|
|
// editor!.hideToolbar(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
if (delegate.selectionEnabled && !_isPositionSelected(details)) { |
|
|
|
if (delegate.selectionEnabled && !_isPositionSelected(details)) { |
|
|
@ -701,6 +701,7 @@ class _QuillEditorSelectionGestureDetectorBuilder |
|
|
|
case PointerDeviceKind.mouse: |
|
|
|
case PointerDeviceKind.mouse: |
|
|
|
case PointerDeviceKind.stylus: |
|
|
|
case PointerDeviceKind.stylus: |
|
|
|
case PointerDeviceKind.invertedStylus: |
|
|
|
case PointerDeviceKind.invertedStylus: |
|
|
|
|
|
|
|
editor!.hideToolbar(); |
|
|
|
// Precise devices should place the cursor at a precise position. |
|
|
|
// Precise devices should place the cursor at a precise position. |
|
|
|
// If `Shift` key is pressed then |
|
|
|
// If `Shift` key is pressed then |
|
|
|
// extend current selection instead. |
|
|
|
// extend current selection instead. |
|
|
@ -724,31 +725,42 @@ class _QuillEditorSelectionGestureDetectorBuilder |
|
|
|
final TextSelection previousSelection = renderEditor!.selection; |
|
|
|
final TextSelection previousSelection = renderEditor!.selection; |
|
|
|
final TextPosition textPosition = renderEditor!.getPositionForOffset(details.globalPosition); |
|
|
|
final TextPosition textPosition = renderEditor!.getPositionForOffset(details.globalPosition); |
|
|
|
final bool isAffinityTheSame = textPosition.affinity == previousSelection.affinity; |
|
|
|
final bool isAffinityTheSame = textPosition.affinity == previousSelection.affinity; |
|
|
|
if (((_positionWasOnSelectionExclusive(textPosition) && !previousSelection.isCollapsed) |
|
|
|
if (((_positionWasOnSelectionExclusive(textPosition) && !previousSelection.isCollapsed) || |
|
|
|
|| (_positionWasOnSelectionInclusive(textPosition) && previousSelection.isCollapsed && isAffinityTheSame)) |
|
|
|
(_positionWasOnSelectionInclusive(textPosition) && |
|
|
|
&& renderEditor!._hasFocus) { |
|
|
|
previousSelection.isCollapsed && |
|
|
|
editor!.showToolbar(); |
|
|
|
isAffinityTheSame)) && |
|
|
|
|
|
|
|
renderEditor!._hasFocus) { |
|
|
|
|
|
|
|
toggleToolbar(false); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
renderEditor! |
|
|
|
renderEditor! |
|
|
|
..selectWordEdge(SelectionChangedCause.tap) |
|
|
|
..selectWordEdge(SelectionChangedCause.tap) |
|
|
|
..onSelectionCompleted(); |
|
|
|
..onSelectionCompleted(); |
|
|
|
if (previousSelection == editor!.textEditingValue.selection && renderEditor!._hasFocus) { |
|
|
|
|
|
|
|
editor!.showToolbar(); |
|
|
|
if (editor!.selectionOverlay?.toolbar != null && previousSelection.start == 0) { |
|
|
|
} else { |
|
|
|
editor!.hideToolbar(true); |
|
|
|
editor!.hideToolbar(false); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future.delayed(const Duration(milliseconds: 300), () { |
|
|
|
|
|
|
|
if (previousSelection == editor!.textEditingValue.selection && renderEditor!._hasFocus) { |
|
|
|
|
|
|
|
toggleToolbar(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
editor!.hideToolbar(); |
|
|
|
renderEditor! |
|
|
|
renderEditor! |
|
|
|
..selectPosition(cause: SelectionChangedCause.tap) |
|
|
|
..selectPosition(cause: SelectionChangedCause.tap) |
|
|
|
..onSelectionCompleted(); |
|
|
|
..onSelectionCompleted(); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case PointerDeviceKind.trackpad: |
|
|
|
case PointerDeviceKind.trackpad: |
|
|
|
|
|
|
|
editor!.hideToolbar(); |
|
|
|
// TODO: Handle this case. |
|
|
|
// TODO: Handle this case. |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
editor!.hideToolbar(); |
|
|
|
renderEditor! |
|
|
|
renderEditor! |
|
|
|
..selectPosition(cause: SelectionChangedCause.tap) |
|
|
|
..selectPosition(cause: SelectionChangedCause.tap) |
|
|
|
..onSelectionCompleted(); |
|
|
|
..onSelectionCompleted(); |
|
|
@ -800,6 +812,15 @@ class _QuillEditorSelectionGestureDetectorBuilder |
|
|
|
super.onSingleLongTapEnd(details); |
|
|
|
super.onSingleLongTapEnd(details); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Toggles the visibility of the toolbar. |
|
|
|
|
|
|
|
void toggleToolbar([bool hideHandles = true]) { |
|
|
|
|
|
|
|
if (editor!.selectionOverlay?.toolbar != null) { |
|
|
|
|
|
|
|
editor!.hideToolbar(hideHandles); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
editor!.showToolbar(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool _positionWasOnSelectionExclusive(TextPosition textPosition) { |
|
|
|
bool _positionWasOnSelectionExclusive(TextPosition textPosition) { |
|
|
|
final TextSelection? selection = renderEditor!.selection; |
|
|
|
final TextSelection? selection = renderEditor!.selection; |
|
|
|
if (selection == null) { |
|
|
|
if (selection == null) { |
|
|
|