onDoubleTapWithPosition method
Implementation
void onDoubleTapWithPosition(
Offset localPosition,
RenderBox renderBox,
Widget widget,
) {
final paragraph = renderBox as RenderFluentParagraph;
final fragmentResult = paragraph.getFragmentAtPosition(localPosition);
if (fragmentResult != null) {
final node = document.nodeById(fragmentResult.fragmentId);
if (node is Fragment) {
final text = node.text;
final offset = fragmentResult.localOffset;
// Find word boundaries
int start = offset;
int end = offset;
// Find start of word
while (start > 0 && _isWordChar(text[start - 1])) {
start--;
}
// Find end of word
while (end < text.length && _isWordChar(text[end])) {
end++;
}
// Set selection to the word
document.cursor.moveTo(node.id, start);
document.cursor.focusTo(node.id, end);
// Sync SelectionManager to show visual selection
_syncSelectionManager(document);
// Double-tap does NOT mutate content: cursor-only update.
document.cursorOnlyUpdate();
}
}
}