“d9f2057692998686e77a83f128506e6e78397100”上不存在“...getstarted/git@gitcode.net:s920243400/PaddleDetection.git”
提交 ec5db192 编写于 作者: L liujinwei

add menu

Signed-off-by: Nliujinwei <hw.liujinwei@huawei.com>
Change-Id: I246683152efaf8638ed0e4dd688c08220fe7720f
上级 c5b3397f
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
| 名称 | 参数类型 | 默认值 | 描述 | | 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bindMenu | Array<MenuItem&gt;&nbsp;\|&nbsp;[CustomBuilder](../../ui/ts-types.md#custombuilder类型8+)<sup>8+</sup> | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 | | bindMenu | Array<MenuItem&gt;&nbsp;\|&nbsp;[CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 |
| bindContextMenu | content:&nbsp;[CustomBuilder](../../ui/ts-types.md)<sup>8+</sup><br>responseType:&nbsp;ResponseType<sup>8+</sup> | - | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 |
- MenuItem - MenuItem
...@@ -23,6 +24,11 @@ ...@@ -23,6 +24,11 @@
| value | string | 菜单项文本。 | | value | string | 菜单项文本。 |
| action | ()&nbsp;=&gt;&nbsp;void | 点击菜单项的事件回调。 | | action | ()&nbsp;=&gt;&nbsp;void | 点击菜单项的事件回调。 |
- ResponseType<sup>8+</sup>
| 参数值 | 描述 |
| -------- | -------- |
| LongPress | 通过长按触发菜单弹出 |
| RightClick | 通过鼠标右键触发菜单弹出 |
## 示例 ## 示例
...@@ -103,3 +109,33 @@ struct MenuExample { ...@@ -103,3 +109,33 @@ struct MenuExample {
``` ```
![zh-cn_image_0000001186807708](figures/zh-cn_image_0000001186807708.gif) ![zh-cn_image_0000001186807708](figures/zh-cn_image_0000001186807708.gif)
```
@Entry
@Component
struct MenuExample {
@Builder MenuBuilder() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text('Test menu item 1')
.fontSize(20)
.width(100)
.height(50)
.textAlign(TextAlign.Center)
Divider().height(10)
Text('Test menu item 2')
.fontSize(20)
.width(100)
.height(50)
.textAlign(TextAlign.Center)
}.width(100)
}
build() {
Column() {
Text('rightclick for menu')
}
.width('100%')
.margin({ top: 5 })
.bindContextMenu(this.MenuBuilder, ResponseType.RightClick)
}
}
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册