Javascript: TXTextControl.addEventListener Method

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

Syntax

TXTextControl.addEventListener(<String> eventName, <function> callback);
Parameter Description
eventName

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


Value Meaning
"ribbonTabsLoaded" Is fired after the ribbon bar content has been loaded completely and the server supplied string resources have been applied.
"textFieldEntered" Is fired when the input position enters a text field.
"textFieldLeft" Is fired when the input position leaves a text field.
"textFieldClicked" Is fired when the user clicks into a text field.
"textDropped" Is fired when RTF text, HTML text or plain text is dragged and dropped onto the control.
"documentLoaded" Is fired after a document has been loaded.
"webSocketClosed" Is fired if the websocket connection is closed.
"textControlLoaded" Is fired after the TextContol instance has been properly initialized and is ready to be used / manipulated programmatically.
"ribbonTabIndexChanged" Is fired after the current ribbon tab index has changed.
"subTextPartEntered" Is fired when the input position enters a sub text part.
"subTextPartLeft" Is fired when the input position leaves a sub text part.
"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.
"hyperlinkClicked" Is fired when the user clicks on a hyperlink.
"textControlChanged" Is fired when the content of the current document has changed.
"inputPositionChanged" Is fired when the text input position 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
"ribbonTabsLoaded" None.
"textFieldEntered" An object of type TextFieldEventArgs.
"textFieldLeft" None.
"textDropped" An object of type TextDroppedEventArgs.
"textFieldClicked" An object of type TextFieldEventArgs.
"documentLoaded" An object of type DocumentLoadedEventArgs.
"webSocketClosed" An object of type WebSocketClosedEventArgs.
"textControlLoaded" None.
"ribbonTabIndexChanged" An object of type RibbonTabIndexChangedEventArgs.
"subTextPartEntered" An object of type SubTextPartEventArgs.
"subTextPartLeft" An object of type SubTextPartEventArgs.
"subTextPartClicked" An object of type SubTextPartEventArgs.
"subTextPartDoubleClicked" An object of type SubTextPartEventArgs.
"hyperlinkClicked" An object of type HyperlinkClickedEventArgs
"textControlChanged" None.
"inputPositionChanged" An object of type InputPositionChangedEventArgs

Example

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

See Also