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

2026-08-25 浏览 (1)

Class (WebContextMenuParam)

Implements a WebContextMenuParam object, which is displayed after the user clicks the right mouse button or long presses a specific element, such as an image or a link. For details about the sample code, see onContextMenuShow.

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

  • The sample effect is subject to the actual device.

constructor9+

constructor()

Constructs a WebContextMenuParam object.

System capability: SystemCapability.Web.Webview.Core

x9+

x(): number

Obtains the X coordinate of the context menu.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
numberIf the display is normal, a non-negative integer is returned. Otherwise, -1 is returned.
Unit: vp.

y9+

y(): number

Obtains the Y coordinate of the context menu.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
numberIf the display is normal, a non-negative integer is returned. Otherwise, -1 is returned.
Unit: vp.

getLinkUrl9+

getLinkUrl(): string

Obtains the URL that has passed the security check.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
stringIf it is a link that is being long pressed, the URL that has passed the security check is returned.

getUnfilteredLinkUrl9+

getUnfilteredLinkUrl(): string

Obtains the original URL.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
stringIf it is a link that is being long pressed, the original URL is returned.

getSourceUrl9+

getSourceUrl(): string

Obtains the source URL.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
stringIf the selected element has the src attribute, the URL in the src is returned. The maximum size of the returned URL is 2 MB. If the size exceeds the upper limit, an empty string is returned.

existsImageContents9+

existsImageContents(): boolean

Checks whether image content exists.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
booleanThe value true means that there is image content in the element being long pressed, and false means the opposite.

getMediaType9+

getMediaType(): ContextMenuMediaType

Obtains the media type of this web page element.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
ContextMenuMediaTypeMedia type of the web page element.

getSelectionText9+

getSelectionText(): string

Obtains the selected text.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
stringSelected text for the context menu. If no text is selected, null is returned.

getSourceType9+

getSourceType(): ContextMenuSourceType

Obtains the event source of the context menu.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
ContextMenuSourceTypeEvent source of the context menu.

getInputFieldType9+

getInputFieldType(): ContextMenuInputFieldType

Obtains the input field type of this web page element.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
ContextMenuInputFieldTypeInput field type.

isEditable9+

isEditable(): boolean

Checks whether this web page element is editable.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
booleantrue is returned if the web page element is editable; otherwise, false is returned.

getEditStateFlags9+

getEditStateFlags(): number

Obtains the edit state flag of this web page element.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
numberEdit state flag of the web page element. For details, see ContextMenuEditStateFlags.

getPreviewWidth13+

getPreviewWidth(): number

Obtains the width of a preview image.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
numberWidth of a preview image.
Unit: vp.

getPreviewHeight13+

getPreviewHeight(): number

Obtains the height of a preview image.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
numberHeight of a preview image.
Unit: vp.

getContextMenuMediaType22+

getContextMenuMediaType(): ContextMenuDataMediaType

Obtains the type of the web page element that the user taps when the context menu event is reported.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
ContextMenuDataMediaTypeMedia type of the web page element.

你可能感兴趣的鸿蒙文章

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/qAemcshQ