• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Class (WebContextMenuParam)
2<!--Kit: ArkWeb-->
3<!--Subsystem: Web-->
4<!--Owner: @zourongchun-->
5<!--Designer: @zhufenghao-->
6<!--Tester: @ghiker-->
7<!--Adviser: @HelloCrease-->
8
9实现长按页面元素或鼠标右键弹出来的菜单信息。示例代码参考[onContextMenuShow事件](./arkts-basic-components-web-events.md#oncontextmenushow9)。
10
11> **说明:**
12>
13> - 该组件首批接口从API version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
14>
15> - 本Class首批接口从API version 9开始支持。
16>
17> - 示例效果请以真机运行为准,当前DevEco Studio预览器不支持。
18
19## constructor<sup>9+</sup>
20
21constructor()
22
23WebContextMenuParam的构造函数。
24
25**系统能力:** SystemCapability.Web.Webview.Core
26
27## x<sup>9+</sup>
28
29x(): number
30
31弹出菜单的x坐标。
32
33**系统能力:** SystemCapability.Web.Webview.Core
34
35**返回值:**
36
37| 类型     | 说明                 |
38| ------ | ------------------ |
39| number | 显示正常返回非负整数,否则返回-1。<br>单位:vp。 |
40
41## y<sup>9+</sup>
42
43y(): number
44
45弹出菜单的y坐标。
46
47**系统能力:** SystemCapability.Web.Webview.Core
48
49**返回值:**
50
51| 类型     | 说明                 |
52| ------ | ------------------ |
53| number | 显示正常返回非负整数,否则返回-1。<br>单位:vp。 |
54
55## getLinkUrl<sup>9+</sup>
56
57getLinkUrl(): string
58
59获取链接地址。
60
61**系统能力:** SystemCapability.Web.Webview.Core
62
63**返回值:**
64
65| 类型     | 说明                        |
66| ------ | ------------------------- |
67| string | 如果长按位置是链接,返回经过安全检查的url链接。 |
68
69## getUnfilteredLinkUrl<sup>9+</sup>
70
71getUnfilteredLinkUrl(): string
72
73获取链接地址。
74
75**系统能力:** SystemCapability.Web.Webview.Core
76
77**返回值:**
78
79| 类型     | 说明                    |
80| ------ | --------------------- |
81| string | 如果长按位置是链接,返回原始的url链接。 |
82
83## getSourceUrl<sup>9+</sup>
84
85getSourceUrl(): string
86
87获取sourceUrl链接。
88
89**系统能力:** SystemCapability.Web.Webview.Core
90
91**返回值:**
92
93| 类型     | 说明                       |
94| ------ | ------------------------ |
95| string | 如果选中的元素有src属性,返回src的url。 |
96
97## existsImageContents<sup>9+</sup>
98
99existsImageContents(): boolean
100
101是否存在图像内容。
102
103**系统能力:** SystemCapability.Web.Webview.Core
104
105**返回值:**
106
107| 类型      | 说明                        |
108| ------- | ------------------------- |
109| boolean | 长按位置中有图片返回true,否则返回false。 |
110
111## getMediaType<sup>9+</sup>
112
113getMediaType(): ContextMenuMediaType
114
115获取网页元素媒体类型。
116
117**系统能力:** SystemCapability.Web.Webview.Core
118
119**返回值:**
120
121| 类型                                       | 说明        |
122| ---------------------------------------- | --------- |
123| [ContextMenuMediaType](./arkts-basic-components-web-e.md#contextmenumediatype9) | 网页元素媒体类型。 |
124
125## getSelectionText<sup>9+</sup>
126
127getSelectionText(): string
128
129获取选中文本。
130
131**系统能力:** SystemCapability.Web.Webview.Core
132
133**返回值:**
134
135| 类型     | 说明                   |
136| ------ | -------------------- |
137| string | 菜单上下文选中文本内容,不存在则返回空。 |
138
139## getSourceType<sup>9+</sup>
140
141getSourceType(): ContextMenuSourceType
142
143获取菜单事件来源。
144
145**系统能力:** SystemCapability.Web.Webview.Core
146
147**返回值:**
148
149| 类型                                       | 说明      |
150| ---------------------------------------- | ------- |
151| [ContextMenuSourceType](./arkts-basic-components-web-e.md#contextmenusourcetype9) | 菜单事件来源。 |
152
153## getInputFieldType<sup>9+</sup>
154
155getInputFieldType(): ContextMenuInputFieldType
156
157获取网页元素输入框类型。
158
159**系统能力:** SystemCapability.Web.Webview.Core
160
161**返回值:**
162
163| 类型                                       | 说明     |
164| ---------------------------------------- | ------ |
165| [ContextMenuInputFieldType](./arkts-basic-components-web-e.md#contextmenuinputfieldtype9) | 输入框类型。 |
166
167## isEditable<sup>9+</sup>
168
169isEditable(): boolean
170
171获取网页元素是否可编辑标识。
172
173**系统能力:** SystemCapability.Web.Webview.Core
174
175**返回值:**
176
177| 类型      | 说明                         |
178| ------- | -------------------------- |
179| boolean | 网页元素可编辑返回true,不可编辑返回false。 |
180
181## getEditStateFlags<sup>9+</sup>
182
183getEditStateFlags(): number
184
185获取网页元素可编辑标识。
186
187**系统能力:** SystemCapability.Web.Webview.Core
188
189**返回值:**
190
191| 类型     | 说明                                       |
192| ------ | ---------------------------------------- |
193| number | 网页元素可编辑标识,参照[ContextMenuEditStateFlags](./arkts-basic-components-web-e.md#contextmenueditstateflags9)。 |
194
195## getPreviewWidth<sup>13+</sup>
196
197getPreviewWidth(): number
198
199获取预览图的宽。
200
201**系统能力:** SystemCapability.Web.Webview.Core
202
203**返回值:**
204
205| 类型     | 说明       |
206| ------ | ----------- |
207| number | 预览图的宽。<br>单位:vp。 |
208
209## getPreviewHeight<sup>13+</sup>
210
211getPreviewHeight(): number
212
213获取预览图的高。
214
215**系统能力:** SystemCapability.Web.Webview.Core
216
217**返回值:**
218
219| 类型     | 说明       |
220| ------ | ----------  |
221| number | 预览图的高。<br>单位:vp。 |