Javascript: TXTextControl.addEventListener Method

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

Syntax

[JavaScript]
TXTextControl.addEventListener(<string> eventName, <function> callback);
Parameter Description
eventName

A string representing the name of the event to listen for.


Value Meaning
"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.
"documentLoaded" Is fired after a document has been loaded.
"fileDropped" Is fired when a file is dragged and dropped onto the control.
"hyperlinkClicked" Is fired when the user clicks on a hyperlink.
"inputPositionChanged" Is fired when the text input position has changed.
"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.
"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.
"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.
"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.
"webSocketClosed" Is fired if the websocket connection is closed.
"zoomFactorChanged" Is fired when the zoom factor of the text editor has changed.
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 Name Event Argument
"clipboardDataTransferAborted" An object of type ClipboardTransferAbortedEventArgs
"clipboardDataTransferComplete" An object of type ClipboardTransferCompleteEventArgs
"clipboardDataTransferProgress" An object of type ClipboardTransferProgressEventArgs
"clipboardDataTransferStart" An object of type ClipboardTransferStartEventArgs
"clipboardModeChanged" An object of type ClipboardModeChangedEventArgs
"documentLoaded" An object of type DocumentLoadedEventArgs.
"fileDropped" An object of type FileDroppedEventArgs.
"hyperlinkClicked" An object of type HyperlinkClickedEventArgs
"inputPositionChanged" An object of type InputPositionChangedEventArgs
"ribbonTabsLoaded" None.
"ribbonTabIndexChanged" An object of type RibbonTabIndexChangedEventArgs.
"subTextPartClicked" An object of type SubTextPartEventArgs.
"subTextPartDoubleClicked" An object of type SubTextPartEventArgs.
"subTextPartEntered" An object of type SubTextPartEventArgs.
"subTextPartLeft" An object of type SubTextPartEventArgs.
"textControlChanged" None.
"textControlLoaded" None.
"textDropped" An object of type TextDroppedEventArgs.
"textFieldClicked" An object of type TextFieldEventArgs.
"textFieldEntered" An object of type TextFieldEventArgs.
"textFieldLeft" None.
"textPasted" An object of type TextPastedEventArgs.
"textViewLocationChanged" An object of type TextViewLocationChangedEventArgs
"webSocketClosed" An object of type WebSocketClosedEventArgs.
"zoomFactorChanged" An object of type ZoomFactorChangedEventArgs

Example

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

[JavaScript]
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

See Also