ApplySelectionEdit
Forms, interaction, edit history
Description
Internal helper of TPDFlibFormSession that performs the atomic replacement transaction behind ReplaceSelection, CutSelection and PasteText
Only text fields and editable choice fields with choice type 4 are accepted, and read-only fields are rejected
The transaction dispatches the Widget /K keystroke action first and then raises OnTextEdit with the edit kind, the UTF-16 selection, the selected text and a mutable replacement; either veto aborts with 0 before the transient value changes
For text fields a configured /MaxLen is enforced by clamping the replacement to the remaining length, cutting only at complete extended grapheme boundaries
An accepted replacement splices the value, collapses the caret after the inserted text, records one history entry and returns the removed text through RemovedText
Declaration
function ApplySelectionEdit(EditKind: TPDFlibFormEditKind;
const ReplacementText: WideString; out RemovedText: WideString): Integer;
Parameters
| EditKind | Kind reported to OnTextEdit, one of fekReplaceSelection, fekCutSelection or fekPasteText |
|---|---|
| ReplacementText | Text that replaces the normalized selection |
| RemovedText | Receives the previously selected text on success, an empty string otherwise |
Return value
Returns 1 when the replacement was accepted, otherwise 0 when the request was reentrant, no editable field is active, the field is read-only or the /K action or OnTextEdit handler vetoed it
See also
ReplaceSelection, CutSelection, PasteText, DeleteEditSelection, DispatchAction, ClampTextLength, AddEditHistory, TPDFlibFormEditKind, TPDFlibFormSessionTextEditEvent, TPDFlibFormSession