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

IndexUnitfsuUTF16CodeUnit, fsuUnicodeCodePoint or fsuGraphemeCluster
SelectionReceives the converted directed and normalised range

Selection fields

IndexUnitUnit used for every returned index and length
AnchorIndexFixed edge of the selection
CaretIndexMoving edge of the selection
StartIndexLesser of the converted anchor and caret positions
SelectionLengthDistance between the ordered converted boundaries
IsReversedTrue 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;

See also

SetSelectionRange, TPDFlibFormSession