BeginEdit

Forms, interaction, edit history

Description

Starts a transactional edit for a text field or a choice field and snapshots the field's current value as OriginalValue

The requested Widget is focused first through FocusField with CommitCurrent set to True, so a previously active edit follows the normal commit, blur and focus action path

On success the edit history is reset, EditValue and DisplayValue are initialized from the field value and the caret is placed at the end of the value

Read-only fields and other field types are rejected, and requesting the Widget that is already focused and being edited returns 1 without taking a new snapshot

Declaration

function BeginEdit(FieldIndex: Integer): Integer;

Parameters

FieldIndexField or temporary Widget index of the editable text or choice field

Return value

Returns 1 when the edit is active, otherwise 0 when the request was reentrant, the field is invalid, read-only or not editable, or focusing failed

Example

if Session.BeginEdit(FieldIndex) = 1 then
  Session.CommitEdit;

See also

CommitEdit, CancelEdit, FocusField, EditingFieldIndex, EditValue, OriginalValue, ClearEditHistory, TPDFlibFormSession