openharmony 鸿蒙 arkts-basic-components-web-EventResult

2026-08-25 浏览 (1)

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

NameTypeMandatoryDescription
resultbooleanYesWhether 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

NameTypeMandatoryDescription
resultbooleanYesWhether 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.
stopPropagationbooleanYesWhether 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

NameTypeMandatoryDescription
resultbooleanYesWhether 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.
stopPropagationbooleanNoWhether 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.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-webview-WebviewController

openharmony 鸿蒙 arkts-apis-webview-t

openharmony 鸿蒙 arkts-apis-webview

openharmony 鸿蒙 capi-arkweb-type-h

openharmony 鸿蒙 arkts-basic-components-web-FullScreenExitHandler

openharmony 鸿蒙 arkts-apis-webview-WebDownloadManager

openharmony 鸿蒙 arkts-basic-components-web-VerifyPinHandler

openharmony 鸿蒙 capi-web-arkweb-webmessage8h

openharmony 鸿蒙 arkts-apis-webview-NativeMediaPlayerHandler

openharmony 鸿蒙 capi-web-arkweb-proxymethodwithresult

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/tWqXWJDj