SetSelection
Forms, interaction, unicode
Description
Stores a selection range expressed in zero-based UTF-16 code units within the transient value of the active edit
Both arguments are clamped to the current value, a negative start or length is treated as zero and the length is reduced so the range never exceeds the value end
The call delegates to SetSelectionRange in fsuUTF16CodeUnit units, places anchor and caret at the range edges and resets the cached visual caret slot
Declaration
function SetSelection(StartIndex, SelectionLength: Integer): Integer;
Parameters
| StartIndex | Zero-based UTF-16 start position, clamped into the range 0 through the current value length |
|---|---|
| SelectionLength | Number of UTF-16 code units to select, clamped to the remaining value length |
Return value
Returns 1 when the range was stored and 0 when no edit is active or the session is applying an edit, history step or commit
Example
Session.BeginEdit(Session.FocusedFieldIndex);
Session.SetSelection(0, 3);
See also
SetSelectionRange, GetSelectionRange, SelectionStart, SelectionLength, TPDFlibFormSelectionUnit