Back to API Reference
Class

SelectionHitTest

static

Line and codepoint navigation helpers shared by the caret hit-test path (HitTestCaret), the editing layer (vertical caret movement, line edges), and selection-extension code.

Remarks

Top-level screen-to-codepoint resolution lives on UniTextBase as the HitTestRange / HitTestCaret instance method pair (range vs. caret are genuinely different operations — the bounding-box hit suits link / range detection while edge-snapping suits caret placement). Helpers in this class compose into both. All methods are pure with respect to layout state — none mutate UniText buffers.
public static int FindLineAtLocalY()

Determines which text line corresponds to the given local-space point. textRect must be the rect the glyph coordinates are relative to (the padded rect).

public static int FindLineAtCodepoint()

Finds the line containing a given codepoint via binary search. With upstream set, codepoints that sit at a soft-wrap boundary resolve to the upstream line (useful for caret affinity).

public static int FindCodepointAtX()

Finds the codepoint index on lineIndex closest to targetX in text-local coordinates. Snaps to grapheme cluster boundaries to keep multi-codepoint sequences atomic. Never returns a position past a trailing mandatory break (see LineCaretEnd). Scans only the line's own glyph span (glyphStart/glyphCount) — the per-call cost is bounded by the line, not the document. Clicks past a visual line edge resolve to the logical line start / end when the edge run follows the paragraph direction, otherwise to the edge glyph's BiDi codepoint (the visual edge — Android getOffsetForHorizontal / Chromium PositionForPoint behavior on mixed-direction lines).