提交 9cf3d74e 编写于 作者: E ester.zhou

update ts-universal-attributes-menu.md

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 4879dc96
# Menu Control # Menu Control
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** This module provides APIs for binding a menu – a vertical list of items – to a component. This menu is displayed by long-pressing, clicking, or right-clicking the component.
> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
> **NOTE**
>
> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -12,29 +15,30 @@ None ...@@ -12,29 +15,30 @@ None
## Attributes ## Attributes
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
| ---------------------------- | ---------------------------------------- | ------------- | ---------------------------------------- | | ---------------------------- | ---------------------------------------- | ---- | ---------------------------------- |
| bindMenu | Array<MenuItem&gt; \| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Menu bound to the component, which is displayed when you click the component. Textual and custom menu items are supported. | | bindMenu | Array<MenuItem&gt;&nbsp;\|&nbsp;[CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Menu bound to the component, which is displayed when you click the component. Textual and custom menu items are supported.|
| bindContextMenu<sup>8+</sup> | content: [CustomBuilder](../../ui/ts-types.md)<br>responseType: ResponseType | - | Context menu bound to the component, which is displayed when you long-press or right-click the component. Only custom menu items are supported. | | bindContextMenu<sup>8+</sup> | content:&nbsp;[CustomBuilder](../../ui/ts-types.md),<br>responseType:&nbsp;ResponseType | - | Context menu bound to the component, which is displayed when you long-press or right-click the component. Only custom menu items are supported. |
- MenuItem - MenuItem
| Name | Type | Description | | Name | Type | Description |
| ------ | ------------- | ---------------------------------------- | | ------ | ----------------------- | ----------- |
| value | string | Menu item text. | | value | string | Menu item text. |
| action | () =&gt; void | Action triggered when a menu item is clicked. | | action | ()&nbsp;=&gt;&nbsp;void | Action triggered when a menu item is clicked.|
- ResponseType<sup>8+</sup> - ResponseType<sup>8+</sup>
| Value | Description | | Value | Description |
| ---------- | ---------------------------------------- | | ---------- | ------------- |
| LongPress | The menu is displayed when the component is long-pressed. | | LongPress | The menu is displayed when the component is long-pressed. |
| RightClick | The menu is displayed when the component is right-clicked. | | RightClick | The menu is displayed when the component is right-clicked.|
## Example ## Example
#### Menu with Textual Menu Items #### Menu with Textual Menu Items
``` ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct MenuExample { struct MenuExample {
...@@ -66,7 +70,8 @@ struct MenuExample { ...@@ -66,7 +70,8 @@ struct MenuExample {
#### Menu with Custom Menu Items #### Menu with Custom Menu Items
``` ```ts
// xxx.ets
import router from '@system.router'; import router from '@system.router';
@Entry @Entry
...@@ -116,7 +121,8 @@ struct MenuExample { ...@@ -116,7 +121,8 @@ struct MenuExample {
#### Context Menu (Displayed Upon Right-Clicking) #### Context Menu (Displayed Upon Right-Clicking)
``` ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct ContextMenuExample { struct ContextMenuExample {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册