Interactive XFA Change Events

Version 2.1161.0 connects native TXFAWidgetRuntime.ReplaceSelection typing and paste operations to the edited field's change event before adopting its new editing buffer

Event properties

PropertyMeaning
prevTextRead-only text in the editing buffer before this replacement, including earlier uncommitted edits
changeWritable replacement text; assigning an empty string suppresses the inserted characters while retaining the selected deletion range
selStartWritable zero-based start of the replaced selection
selEndWritable exclusive end of the replaced selection
newTextRead-only text computed immediately from prevText, the current selection and change

Selection indices count UTF-16 code units; the runtime rejects negative, fractional, out-of-range and split-surrogate boundaries

Moving one selection endpoint past the other collapses the other endpoint to the new position; assigning newText raises a read-only error

Filter an edit

Attach this JavaScript to the field's event with activity="change" and enable ScriptOptions.EnableJavaScript

const edit = xfa.event;
edit.change = edit.change.toUpperCase();
this.parent.status.rawValue = edit.prevText + "|" + edit.newText;

For an existing buffer a, replacing an empty selection at index 1 with b produces aB; a following uncommitted replacement sees aB as prevText

When JavaScript execution is enabled, compiled FormCalc uses the same context through $event, including writes such as $event.change = Upper($event.change)

Commit and recovery

The change operation publishes its successful script actions and filtered editing buffer together; ordinary typing commits the edited field's native raw value through the existing CommitEdit validation and calculation lifecycle, or through a focus-driven commit

Invalid script output, resource exhaustion, a thrown script, a retired input or failed layout restores the pre-operation document, widgets, editing buffer, focus and retained script state

Data XML response replay and dynamic evaluation preserve the edit payload; typed remerge continuation retains a proved accepted input, while a removed or ambiguous source restores the previous state rather than applying text to another field at the same position

The runtime retains the configured character, value, operation, time and reflow limits; no reader launch or desktop widget is required

Scope

Version 2.1169.0 also runs eligible ancestor change listeners; the direct editing path is used only when neither a local handler nor an eligible ancestor listener is present

Manual DispatchEvent("change") retains its legacy empty payload because it does not describe a typing selection

The JavaScript-disabled literal event parser retains its existing limited grammar; general native FormCalc event expressions remain outside that parser

See Interactive Dynamic XFA Widget Runtime and the XFA 3.3 event model