When a component triggers an event, the processing function bound to the logic layer receives an event object. The object contains the following fields.
Name | Type | Description |
|---|---|---|
type | string | Event type. |
timeStamp | integer | Timestamp when an event is generated. |
object | Attribute value set of the component that triggers the event. | |
object | Attribute value set of the current component. | |
object | Detailed information about the custom event object. | |
array | Information array of touch points on the screen in a touch event. | |
array | Information array of touch points changed in a touch event. |
Indicates the source component that triggers an event.
Name | Type | Description |
|---|---|---|
id | string | ID of the component that triggers an event. |
object | A set of custom attributes starting with data- in the component that triggers the event. |
Indicates the current component bound to an event.
Name | Type | Description |
|---|---|---|
id | string | ID of the component that triggers an event. |
object | A set of custom attributes starting with data- in the component that triggers the event. |
When view3 is tapped, the event objects target and currentTarget received by handleTap3 are view3, but that received by handleTap2 are view3 and view2 respectively.
You can define some custom data in the component node. When an event is triggered, the data is passed to the callback for processing.
In HXML, the custom data starts with data- or data, and multiple words are separated by hyphens (-). In this case, hyphens are replaced with the CamelCase style, and uppercase characters are automatically converted to lowercase characters. For example:
touches is an array. Each element is a Touch object, indicating the touch point that currently stays on the screen.
Name | Type | Description |
|---|---|---|
identifier | number | Identifier of a touch point. |
pageX, pageY | number | Distance from the upper left corner of a document. The upper left corner is the origin, the horizontal axis is X, and the vertical axis is Y. |
clientX, clientY | number | Distance from the upper left corner of the visible area (excluding the navigation bar) on the page. The horizontal axis is X, and the vertical axis is Y. |
The data format of changedTouches is the same as that of touches. It indicates a changed touch point, for example, touchstart (a touch starts), touchmove (a touch moves), or touchend/touchcancel (a touch ends).