SetSelectionRange
Forms, interaction, Unicode
Description
Sets the anchor and caret of the active form-field edit selection in the requested index unit
SelectionStart and SelectionLength properties remain ordered
Code-point and grapheme-cluster units always resolve to valid Unicode boundaries and cannot divide a surrogate pair, combining sequence or joined emoji cluster
Code-point and grapheme-cluster units always resolve to valid Unicode boundaries and cannot divide a surrogate pair, combining sequence or joined emoji cluster
Declaration
function SetSelectionRange(AnchorIndex, CaretIndex: Integer;
IndexUnit: TPDFlibFormSelectionUnit): Integer;
Parameters
| AnchorIndex | Fixed edge of the directed selection in IndexUnit, clamped to the editable value |
|---|---|
| CaretIndex | Moving edge of the directed selection in IndexUnit, clamped to the editable value |
| IndexUnit | fsuUTF16CodeUnit, fsuUnicodeCodePoint or fsuGraphemeCluster |
Return value
Returns 1 when an edit is active and the selection is stored, otherwise 0
Performance
Code-point and grapheme boundary tables are built lazily for the current edit value, reused by later selection operations and invalidated by SetEditValue
Example
if Session.BeginEdit(FieldIndex) = 1 then
begin
Session.SetEditValue('A' + WideChar($D83D) + WideChar($DE00) + 'B');
Session.SetSelectionRange(1, 2, fsuUnicodeCodePoint);
end;