Class (EventResult)

Represents the event consumption result sent to the Web component. For details about the supported events, see TouchType, MouseAction, and left, middle, and right buttons in MouseButton.

If 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.

For details about the sample code of the touch event, see onNativeEmbedGestureEvent.

For details about the sample code of the mouse event, see onNativeEmbedMouseEvent.

NOTE

  • 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.

  • The initial APIs of this class are supported since API version 12.

  • The sample effect is subject to the actual device.

constructor12+

constructor()

Constructs a EventResult object.

System capability: SystemCapability.Web.Webview.Core

setGestureEventResult12+

setGestureEventResult(result: boolean): void

Sets the gesture event consumption result.

System capability: SystemCapability.Web.Webview.Core

Parameters

Name Type Mandatory Description
result boolean Yes Whether to consume the gesture event.
The value true means to consume the gesture event, and false means the opposite.
If null or undefined is passed in, the value is true.

Example

For details, see onNativeEmbedGestureEvent.

setGestureEventResult14+

setGestureEventResult(result: boolean, stopPropagation: boolean): void

Sets the gesture event consumption result.

System capability: SystemCapability.Web.Webview.Core

Parameters

Name Type Mandatory Description
result boolean Yes Whether to consume the gesture event.
The value true means to consume the gesture event, and false means the opposite.
If null or undefined is passed in, the value is true.
stopPropagation boolean Yes Whether to stop propagation. This parameter is valid only when result is set to true.
The value true means to stop propagation, and false means the opposite.
If null or undefined is passed in, the value is true.

Example

For details, see onNativeEmbedGestureEvent.

setMouseEventResult20+

setMouseEventResult(result: boolean, stopPropagation?: boolean): void

Sets the mouse event consumption result.

System capability: SystemCapability.Web.Webview.Core

Parameters

Name Type Mandatory Description
result boolean Yes Whether to consume the mouse event.
The value true means to consume the mouse event, and false means the opposite.
If null or undefined is passed in, the value is true.
stopPropagation boolean No Whether to stop propagation. This parameter is valid only when result is set to true.
The value true means to stop propagation, and false means the opposite.
If null or undefined is passed in, the value is true.

Example

For details, see onNativeEmbedMouseEvent.