Events

Framework control events defined in Description.json should be triggered in Source.js. The name of the event must be named like the "name" of the event in Description.json. An event can be triggered in different situations, e.g. when a certain record changes (see ".onDataChanged" in the data grid).

An event is triggered in Source.js via the EventProvider of the framework. The framework API function "EventProvider.raise()" is used for this purpose. When the event is triggered, the concrete control instance must be identified with "this.__id".

// raise .onMyCustomEvent event
TcHmi.EventProvider.raise(this.__id + '.onMyCustomEvent);

Optionally, parameters can be passed to the event callbacks when the event is triggered.

// declare parameter: type anything
var myParameterObject = 42;
// raise .onMyCustomEvent event with event parameters
TcHmi.EventProvider.raise(this.__id + '.onMyCustomEvent, myParameterObject);

The response to the triggered events can take place in Engineering via the Properties window or via the registration of the event in a Code Behind file.

Events 1:

If allowPreventDefault is allowed in the event definition, the myParameterObject should offer preventDefault as a function. All DOM and jQuery event objects meet this requirement, for example. This function is called if the user has set the option for this event in Engineering.