diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index ac768804a52d97e332ec964f02b190425ac5e609..ba903b5b7674fbf3a3e5d8639a807b520e25507c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -14,15 +14,21 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| bindMenu | Array8+ | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 | +| bindMenu | Array8+ | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 | +| bindContextMenu | content: [CustomBuilder](../../ui/ts-types.md)8+
responseType: ResponseType8+ | - | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | - MenuItem - | 名称 | 类型 | 描述 | + | 名称 | 类型 | 描述 | | -------- | -------- | -------- | - | value | string | 菜单项文本。 | - | action | () => void | 点击菜单项的事件回调。 | + | value | string | 菜单项文本。 | + | action | () => void | 点击菜单项的事件回调。 | +- ResponseType8+ + | 参数值 | 描述 | + | -------- | -------- | + | LongPress | 通过长按触发菜单弹出 | + | RightClick | 通过鼠标右键触发菜单弹出 | ## 示例 @@ -103,3 +109,33 @@ struct MenuExample { ``` ![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