Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
21e371a9
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
21e371a9
编写于
3月 09, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 09, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1874 Add the description of menu interface
Merge pull request !1874 from jinweiliu/030901
上级
0035a645
599f747f
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
87 addition
and
4 deletion
+87
-4
zh-cn/application-dev/reference/arkui-ts/Readme-CN.md
zh-cn/application-dev/reference/arkui-ts/Readme-CN.md
+1
-0
zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md
zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md
+39
-0
zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md
...on-dev/reference/arkui-ts/ts-universal-attributes-menu.md
+47
-4
未找到文件。
zh-cn/application-dev/reference/arkui-ts/Readme-CN.md
浏览文件 @
21e371a9
...
...
@@ -138,5 +138,6 @@
-
[
自定义弹窗
](
ts-methods-custom-dialog-box.md
)
-
[
日期时间选择弹窗
](
ts-methods-datepicker-dialog.md
)
-
[
文本选择弹窗
](
ts-methods-textpicker-dialog.md
)
-
[
菜单
](
ts-methods-menu.md
)
-
附录
-
[
文档中涉及到的内置枚举值
](
ts-appendix-enums.md
)
zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md
0 → 100644
浏览文件 @
21e371a9
# 菜单
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 从 API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## ContextMenu.close
close(): void
可以通过该方法在页面范围内关闭通过
[
bindContextMenu
](
./ts-universal-attributes-menu.md#属性
)
给组件绑定的菜单。
-
示例
```
@Entry
@Component
struct Index {
@Builder MenuBuilder(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('close')
.fontSize(30)
.fontWeight(FontWeight.Bold)
.onClick(() => {
ContextMenu.close();
})
}.height(400)
.backgroundColor(Color.Pink)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
Column(){
Text("Text")
}.bindContextMenu(this.MenuBuilder, ResponseType.LongPress)
}
.width('100%')
.height('100%')
}
}
```
zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md
浏览文件 @
21e371a9
...
...
@@ -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
<sup>
8+
</sup>
| content:
[CustomBuilder](../../ui/ts-types.md)
<br>
responseType:
ResponseType | - | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 |
-
MenuItem
...
...
@@ -23,9 +24,16 @@
| value | string | 菜单项文本。 |
| action | ()
=
>
void | 点击菜单项的事件回调。 |
-
ResponseType
<sup>
8+
</sup>
| 参数值 | 描述 |
| -------- | -------- |
| LongPress | 通过长按触发菜单弹出。 |
| RightClick | 通过鼠标右键触发菜单弹出。 |
## 示例
#### 普通菜单
```
@Entry
@Component
...
...
@@ -56,6 +64,8 @@ struct MenuExample {
![
zh-cn_image_0000001174582862
](
figures/zh-cn_image_0000001174582862.gif
)
#### 自定义内容菜单
```
import router from '@system.router';
...
...
@@ -103,3 +113,36 @@ struct MenuExample {
```
![
zh-cn_image_0000001186807708
](
figures/zh-cn_image_0000001186807708.gif
)
#### 菜单(右键触发显示)
```
@Entry
@Component
struct ContextMenuExample {
@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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录