GetSelectionRange
Forms, interaction, Unicode
Description
Queries the active form-field edit selection without changing its direction or contents
The returned record contains the directed anchor and caret together with an ordered start and length in the requested index unit
Declaration
function GetSelectionRange(IndexUnit: TPDFlibFormSelectionUnit;
out Selection: TPDFlibFormSelection): Integer;
Parameters
| IndexUnit | fsuUTF16CodeUnit, fsuUnicodeCodePoint or fsuGraphemeCluster |
|---|---|
| Selection | Receives the converted directed and normalized range |
Selection fields
| IndexUnit | Unit used for every returned index and length |
|---|---|
| AnchorIndex | Fixed edge of the selection |
| CaretIndex | Moving edge of the selection |
| StartIndex | Lesser of the converted anchor and caret positions |
| SelectionLength | Distance between the ordered converted boundaries |
| IsReversed | True when the internal UTF-16 anchor follows the caret |
Return value
Returns 1 when an edit is active and the selection is returned, otherwise clears Selection and returns 0
Example
var
Selection: TPDFlibFormSelection;
begin
if Session.GetSelectionRange(fsuGraphemeCluster, Selection) = 1 then
GraphemeCount := Selection.SelectionLength;
end;