Skip to content
pixi-silk
GitHub repository
Function

caretAtPoint

import { caretAtPoint } from 'pixi-silk/text';
function caretAtPoint(
   layout: TextLayout, 
   x: number, 
   y: number, 
   isStop?: (index: number) => boolean
): CaretHit;

The caret position nearest to a point, in the layout’s own units (the top left of the text box is 0, 0). Points above the first line or below the last snap to them. isStop filters the offsets a caret may take, for example grapheme cluster boundaries.

Parameters#

ParameterType
layoutTextLayout
xnumber
ynumber
isStop?(index: number) => boolean

Returns#

CaretHit