The addEventListener function registers event listener functions on the TXTextControl object.

<void> TXTextControl.addEventListener(<string> eventName, <function> callback)

Parameters

Parameter Description
eventName A string representing the name of the event to listen for.
Event Description
"barcodeCreated" Is fired when a new barcode has been created.
"barcodeDeleted" Is fired when a barcode has been deleted.
"barcodeDeselected" Is fired when a barcode has been deselected.
"barcodeSelected" Is fired when a barcode has been selected.
"cannotTrackChange" Is fire when a change of the document cannot be added to the list of tracked changes.
"changed" Is fired when the document's content is changed.
"charFormatChanged" Is fired when the character formatting attributes either of the selected characters or the current text input position have been changed.
"chartCreated" Is fired when a new chart has been created.
"chartDeleted" Is fired when a chart has been deleted.
"chartDeselected" Is fired when a chart has been deselected.
"chartSelected" Is fired when a chart has been selected.
"clipboardDataTransferAborted" Is fired when an ongoing clipboard data transfer is aborted.
"clipboardDataTransferComplete" Is fired when a clipboard data transfer is completed.
"clipboardDataTransferProgress" Is fired for each transfered clipboard data packet.
"clipboardDataTransferStart" Is fired when a clipboard data transfer starts.
"clipboardModeChanged" Is fired when the clipboard mode has changed.
"contentsReset" Is fired when all text contents have been deleted and all attributes have been reset to the state after initialization.
"documentLinkClicked" Is fired when a text field has been clicked on that represents a link to a target in the document.
"documentLoaded" Is fired after a document has been loaded.
"documentSizeChanged" Is fired when the document's size is changed.
"drawingActivated" Is fired when a drawing has been activated.
"drawingCreated" Is fired when a new drawing has been created.
"drawingDeactivated" Is fired when a drawing has been deactivated.
"drawingDeleted" Is fired when a drawing has been deleted.
"drawingDeselected" Is fired when a drawing has been deselected.
"drawingSelected" Is fired when a drawing has been selected.
"editableRegionCreated" Is fired when an editable region has been created.
"editableRegionDeleted" Is fired when an editable region has been deleted.
"editableRegionEntered" Is fired when the current input position has been moved to a position that belongs to an editable region.
"editableRegionLeft" Is fired when the current input position has left an editable region.
"fileDropped" Is fired when a file is dragged and dropped onto the control.
"frameDeselected" Is fired when a frame (image, text frame, chart, barcode or drawing) has been deselected.
"frameMoved" Is fired when a frame (image, text frame, chart, barcode or drawing) has been moved.
"frameSelected" Is fired when a frame (image, text frame, chart, barcode or drawing) has been selected.
"frameSized" Is fired when a frame (image, text frame, chart, barcode or drawing) has been sized.
"headerFooterActivated" Is fired when a header or footer gets the current text input position from another part of the document such as a text frame or the main text.
"headerFooterDeactivated" Is fired when a header or footer loses the current text input position and another part of the document such as a text frame or the main text gets it.
"hypertextLinkClicked" Is fired when a text field has been clicked on that represents the source of a hypertext link.
"hyperlinkClicked" Is fired when the user clicks on a hyperlink.
"hyphenateWord" Is fired, if a word does not fit in the line and must be hyphenated.
"imageCreated" Is fired when a new image has been created.
"imageDeleted" Is fired when an image has been deleted.
"imageDeselected" Is fired when an image has been deselected.
"imageSelected" Is fired when an image has been selected.
"inputPositionChanged" Is fired when the text input position has changed.
"mainTextActivated" Is fired when the main text of the document gets the current text input position from another part of the document, such as a header, a footer or a text frame.
"pageFormatChanged" Is fired when the page format settings have been changed.
"paragraphFormatChanged" Is fired when the formatting attributes of the selected paragraphs have been changed.
"removeCombobox" Is fired when a combobox for a SelectionFormField must be removed
"ribbonTabsLoaded" Is fired after the ribbon bar content has been loaded completely and the server supplied string resources have been applied.
"ribbonTabIndexChanged" Is fired after the current ribbon tab index has changed.
"spellCheckText" Is fired, if the document's text has been altered and the spelling of the new text must be checked.
"subTextPartCreated" Is fired when a subtextpart has been created.
"subTextPartDeleted" Is fired when a subtextpart has been deleted.
"subTextPartClicked" Is fired when the user clicks into a sub text part.
"subTextPartDoubleClicked" Is fired when the user double clicks into a sub text part.
"subTextPartEntered" Is fired when the input position enters a sub text part.
"subTextPartLeft" Is fired when the input position leaves a sub text part.
"tableCreated" Is fired after a new table has been created as a result of a text insertion via the clipboard or when loading a document which contains a table without an identifier.
"tableDeleted" Is fired after a table has been deleted.
"textControlChanged" Is fired when the content of the current document has changed.
"textControlLoaded" Is fired after the TextContol instance has been properly initialized and is ready to be used / manipulated programmatically.
"textDropped" Is fired when RTF text, HTML text or plain text is dragged and dropped onto the control.
"textFieldClicked" Is fired when the user clicks into a text field.
"textFieldEntered" Is fired when the input position enters a text field.
"textFieldLeft" Is fired when the input position leaves a text field.
"textFrameActivated" Is fired when a text frame gets the current text input position from another part of the document such as a header, a footer or the main text.
"textFrameCreated" Is fired when a new text frame has been created.
"textFrameDeactivated" Is fired when a text frame loses the current text input position and another part of the document such as a header, a footer or the main text gets it.
"textFrameDeleted" Is fired when a text frame has been deleted.
"textFrameDeselected" Is fired when a text frame has been deselected.
"textFrameSelected" Is fired when a text frame has been selected.
"textPasted" Is fired when RTF text, HTML text or plain text is pasted into the control via Ctrl-V.
"textViewLocationChanged" Is fired when the position of the text view has changed.
"trackedChangeChanged" Is fired when the text of a tracked change has been altered.
"trackedChangeCreated" Is fired when a tracked change has been created.
"trackedChangeDeleted" Is fired when a tracked change has been deleted.
"trackedChangeStateChanged" Is fired when the state of a tracked change alters from active to inactive or vice versa.
"webSocketClosed" Is fired if the websocket connection is closed.
"zoomFactorChanged" Is fired when the zoom factor of the text editor has changed.
"unhandledError" Is fired before an error will be thrown.
callback The event listener. Depending on the event specified in parameter eventName the event listener function is called with different event argument objects (or none at all).
Event Description
"barcodeCreated" BarcodeCallback
"barcodeDeleted" BarcodeCallback
"barcodeDeselected" BarcodeCallback
"barcodeSelected" BarcodeCallback
"cannotTrackChange" CannotTrackChangeCallback
"changed" EventCallback
"charFormatChanged" EventCallback
"chartCreated" ChartCallback
"chartDeleted" ChartCallback
"chartDeselected" ChartCallback
"chartSelected" ChartCallback
"clipboardDataTransferAborted" ClipboardDataTransferAbortedCallback
"clipboardDataTransferComplete" ClipboardDataTransferCompleteCallback
"clipboardDataTransferProgress" ClipboardDataTransferProgressCallback
"clipboardDataTransferStart" ClipboardDataTransferStartCallback
"clipboardModeChanged" ClipboardModeChangedCallback
"contentsReset" EventCallback
"documentLinkClicked" DocumentLinkCallback
"documentLoaded" DocumentLoadedCallback
"documentSizeChanged" RequestSizeCallback
"drawingActivated" DrawingCallback
"drawingCreated" DrawingCallback
"drawingDeactivated" DrawingCallback
"drawingDeleted" DrawingCallback
"drawingDeselected" DrawingCallback
"drawingSelected" DrawingCallback
"editableRegionCreated" EditableRegionCallback
"editableRegionDeleted" EditableRegionCallback
"editableRegionEntered" EditableRegionCallback
"editableRegionLeft" EditableRegionCallback
"fileDropped" FileDroppedCallback
"frameDeselected" FrameCallback
"frameMoved" FrameCallback
"frameSelected" FrameCallback
"frameSized" FrameCallback
"headerFooterActivated" HeaderFooterCallback
"headerFooterDeactivated" HeaderFooterCallback
"hypertextLinkClicked" HypertextLinkClickedCallback
"hyperlinkClicked" HyperlinkClickedCallback
"hyphenateWord" HyphenateWordCallback
"imageCreated" ImageCallback
"imageDeleted" ImageCallback
"imageDeselected" ImageCallback
"imageSelected" ImageCallback
"inputPositionChanged" InputPositionChangedCallback
"mainTextActivated" EventCallback
"pageFormatChanged" EventCallback
"paragraphFormatChanged" EventCallback
"removeCombobox" EventCallback
"ribbonTabsLoaded" RibbonTabsLoadedCallback
"ribbonTabIndexChanged" RibbonTabIndexChangedCallback
"spellCheckText" SpellCheckTextCallback
"subTextPartCreated" SubTextPartCallback
"subTextPartDeleted" SubTextPartCallback
"subTextPartClicked" SubTextPartCallback
"subTextPartDoubleClicked" SubTextPartCallback
"subTextPartEntered" SubTextPartCallback
"subTextPartLeft" SubTextPartCallback
"tableCreated" TableCallback
"tableDeleted" TableCallback
"textControlChanged" TextControlChangedCallback
"textControlLoaded" TextControlLoadedCallback
"textDropped" TextDroppedCallback
"textFieldClicked" TextFieldCallback
"textFieldEntered" TextFieldCallback
"textFieldLeft" TextFieldLeftCallback
"textPasted" TextPastedCallback
"textFrameActivated" TextFrameCallback
"textFrameCreated" TextFrameCallback
"textFrameDeactivated" TextFrameCallback
"textFrameDeleted" TextFrameCallback
"textFrameDeselected" TextFrameCallback
"textFrameSelected" TextFrameCallback
"trackedChangeChanged" TrackedChangeCallback
"trackedChangeCreated" TrackedChangeCallback
"trackedChangeDeleted" TrackedChangeCallback
"trackedChangeStateChanged" TrackedChangeCallback
"textViewLocationChanged" TextViewLocationChangedCallback
"webSocketClosed" WebSocketClosedCallback
"zoomFactorChanged" ZoomFactorChangedCallback
"unhandledError" ErrorCallback

Examples

The following example shows how to attach an event handler to the "textFieldClicked" event.

function fieldClickedHandler(e) 
{ 
console.log("Field type: " + e.fieldType); 
console.log("Field name: " + e.fieldName); 
console.log("Merge field type: " + e.typeName); 
} 

TXTextControl.addEventListener("textFieldClicked", fieldClickedHandler); 

Possible console output after clicking into a merge field: 
> Field type: APPLICATIONFIELD 
> Field name: SalesOrderID 
> Merge field type: MERGEFIELD

Further Reading

Learn more about the Javascript: TXTextControl.addEventListener Method in the Text Control Blog: