Back to API Reference
Interface

ITextInputContext

abstract

Authoritative committed-document, selection, and geometry surface for native text input.

Remarks

Offsets use UTF-16 code units, coordinates use Unity screen pixels, and calls use the reporter epoch's creating thread.

Implementations(1)

Types that implement ITextInputContext.

public int CharCount{ get }

Committed document length in UTF-16 code units.

public string InitialText{ get }

Full committed text used to seed a native field overlay when it is shown.

public abstract int CopyCharRange()

Copies committed chars [charStart, charStart + charLength) into destination, clamping to document bounds and destination capacity. Returns the number of chars actually written.

public abstract ValueTuple<int,int> GetCharSelection()

Current selection normalised to (start, length); a collapsed caret reports (caret, 0).

public abstract void SelectCharRange()

Moves the selection to the given char range (platform replacementRange semantics — the subsequent text insert overwrites the range). Length 0 places a caret.

public abstract bool TryGetCharRangeRect()

Screen rect of the range's portion on its first line (macOS firstRectForCharacterRange:, iOS firstRectForRange: — the OS aligns accent pickers, dictation highlights, and candidate windows to it). Returns false when no layout is available yet.

public abstract int HitTestChar()

Char offset closest to a screen point, or -1 when no layout is available.

public abstract int TokenizerQuery()

Text-unit navigation for the platform tokenizer (iOS UITextInputTokenizer and macOS equivalents). granularity: 0 = character (grapheme), 1 = word. direction: 0 = forward, 1 = backward. action: 0 = position toward boundary, 1 = is-at-boundary, 2 = enclosing-range start, 3 = enclosing-range end, 4 = is-within-unit. Returns a char offset for position queries, 0 / 1 for boolean queries, -1 when unsupported.

public abstract int WritingDirection()

BiDi writing direction at a char offset: 0 = natural / unknown, 1 = LTR, 2 = RTL.