• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Class (EventResult)
2
3Represents the event consumption result sent to the **Web** component. For details about the supported events, see [TouchType](../apis-arkui/arkui-ts/ts-appendix-enums.md#touchtype), [MouseAction](../apis-arkui/arkui-ts/ts-appendix-enums.md#mouseaction8), and left, middle, and right buttons in [MouseButton](../apis-arkui/arkui-ts/ts-appendix-enums.md#mousebutton8).
4
5If the application does not consume the event, set the consumption result to **false**, and the event will be consumed by the **Web** component. If the application consumes the event, set the consumption result to **true**, and the **Web** component will not consume the event. If the consumption result is not set according to the preceding specifications, exceptions may occur.
6
7For details about the sample code of the touch event, see [onNativeEmbedGestureEvent](./arkts-basic-components-web-events.md#onnativeembedgestureevent11).
8For details about the sample code of the mouse event, see [onNativeEmbedMouseEvent](./arkts-basic-components-web-events.md#onnativeembedmouseevent20).
9
10> **NOTE**
11>
12> - The initial APIs of this component are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
13>
14> - The initial APIs of this class are supported since API version 12.
15>
16> - You can preview how this component looks on a real device, but not in DevEco Studio Previewer.
17
18## constructor<sup>12+</sup>
19
20constructor()
21
22Constructs a **EventResult** object.
23
24**System capability**: SystemCapability.Web.Webview.Core
25
26## setGestureEventResult<sup>12+</sup>
27
28setGestureEventResult(result: boolean): void
29
30Sets the gesture event consumption result.
31
32**System capability**: SystemCapability.Web.Webview.Core
33
34**Parameters**
35
36| Name         | Type| Mandatory | Description            |
37| --------------- | -------- | ----  |------- |
38| result          | boolean  | Yes   | Whether to consume the gesture event.<br>The value **true** means to consume the gesture event, and **false** means the opposite. The default value is **true**.|
39
40**Example**
41
42For details, see [onNativeEmbedGestureEvent](./arkts-basic-components-web-events.md#onnativeembedgestureevent11).
43
44## setGestureEventResult<sup>14+</sup>
45
46setGestureEventResult(result: boolean, stopPropagation: boolean): void
47
48Sets the gesture event consumption result.
49
50**System capability**: SystemCapability.Web.Webview.Core
51
52**Parameters**
53
54| Name         | Type| Mandatory | Description            |
55| --------------- | -------- | ----  |------- |
56| result          | boolean  | Yes   | Whether to consume the gesture event.<br>The value **true** means to consume the gesture event, and **false** means the opposite.<br>The default value is **true**.|
57| stopPropagation | boolean  | Yes  | Whether to stop propagation. This parameter is valid only when **result** is set to **true**.<br>The value **true** means to stop propagation, and **false** means the opposite.<br>The default value is **true**.|
58
59**Example**
60
61For details, see [onNativeEmbedGestureEvent](./arkts-basic-components-web-events.md#onnativeembedgestureevent11).
62
63## setMouseEventResult<sup>20+</sup>
64
65setMouseEventResult(result: boolean, stopPropagation?: boolean): void
66
67Sets the mouse event consumption result.
68
69**System capability**: SystemCapability.Web.Webview.Core
70
71**Parameters**
72
73| Name         | Type| Mandatory | Description            |
74| --------------- | -------- | ----  |------- |
75| result          | boolean  | Yes   | Whether to consume the mouse event.<br>The value **true** means to consume the mouse event, and **false** means the opposite.<br>The default value is **true**.|
76| stopPropagation | boolean  | No  | Whether to stop propagation. This parameter is valid only when **result** is set to **true**.<br>The value **true** means to stop propagation, and **false** means the opposite.<br>The default value is **true**.|
77
78**Example**
79
80For details, see [onNativeEmbedMouseEvent](./arkts-basic-components-web-events.md#onnativeembedmouseevent20).
81