Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
ec08d637
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看板
未验证
提交
ec08d637
编写于
11月 11, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
!11354 修改示例代码错误
Merge pull request !11354 from mayunteng/master1
上级
c92bdf57
6caf5e29
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
25 deletion
+44
-25
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md
...n/application-dev/reference/apis/js-apis-inputconsumer.md
+11
-4
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
+20
-14
zh-cn/application-dev/reference/apis/js-apis-pointer.md
zh-cn/application-dev/reference/apis/js-apis-pointer.md
+9
-3
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md
浏览文件 @
ec08d637
...
...
@@ -36,9 +36,10 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): v
**示例:**
```
js
let
powerKeyCode
=
18
;
let
leftAltKey
=
2045
;
let
tabKey
=
2049
;
try
{
inputConsumer
.
on
(
"
key
"
,
{
preKeys
:
[
],
finalKey
:
powerKeyCode
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
},
keyOptions
=>
{
inputConsumer
.
on
(
"
key
"
,
{
preKeys
:
[
leftAltKey
],
finalKey
:
tabKey
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
},
keyOptions
=>
{
console
.
log
(
`keyOptions:
${
JSON
.
stringify
(
keyOptions
)}
`
);
});
}
catch
(
error
)
{
...
...
@@ -66,27 +67,33 @@ off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>):
**示例:**
```
js
let
leftAltKey
=
2045
;
let
tabKey
=
2049
;
// 取消订阅单个回调函数
let
callback
=
function
(
keyOptions
)
{
console
.
log
(
`keyOptions:
${
JSON
.
stringify
(
keyOptions
)}
`
);
}
let
keyOption
=
{
preKeys
:
[
],
finalKey
:
powerKeyCode
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
};
let
keyOption
=
{
preKeys
:
[
leftAltKey
],
finalKey
:
tabKey
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
};
try
{
inputConsumer
.
on
(
"
key
"
,
keyOption
,
callback
);
inputConsumer
.
off
(
"
key
"
,
keyOption
,
callback
);
console
.
log
(
`Unsubscribe success`
);
}
catch
(
error
)
{
console
.
log
(
`Execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
```
```
js
let
leftAltKey
=
2045
;
let
tabKey
=
2049
;
// 取消订阅所有回调函数
let
callback
=
function
(
keyOptions
)
{
console
.
log
(
`keyOptions:
${
JSON
.
stringify
(
keyOptions
)}
`
);
}
let
keyOption
=
{
preKeys
:
[
],
finalKey
:
powerKeyCode
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
};
let
keyOption
=
{
preKeys
:
[
leftAltKey
],
finalKey
:
tabKey
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
};
try
{
inputConsumer
.
on
(
"
key
"
,
keyOption
,
callback
);
inputConsumer
.
off
(
"
key
"
,
keyOption
);
console
.
log
(
`Unsubscribe success`
);
}
catch
(
error
)
{
console
.
log
(
`Execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
...
...
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
浏览文件 @
ec08d637
...
...
@@ -194,19 +194,19 @@ off(type: "change", listener?: Callback<DeviceListener>): void
**示例**
:
```
js
callback
:
function
(
data
)
{
function
callback
(
data
)
{
console
.
log
(
`Report device event info:
${
JSON
.
stringify
(
data
,
[
`type`
,
`deviceId`
])}
`
);
}
}
;
try
{
inputDevice
.
on
(
"
change
"
,
this
.
callback
);
inputDevice
.
on
(
"
change
"
,
callback
);
}
catch
(
error
)
{
console
.
log
(
`Listen device event failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
// 取消指定的监听。
try
{
inputDevice
.
off
(
"
change
"
,
this
.
callback
);
inputDevice
.
off
(
"
change
"
,
callback
);
}
catch
(
error
)
{
console
.
log
(
`Cancel listening device event failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
浏览文件 @
ec08d637
...
...
@@ -96,13 +96,14 @@ off(type: "touch", receiver?: TouchEventReceiver): void
```
js
// 取消监听单个回调函数
callback
:
function
(
touchEvent
)
{
function
callback
(
touchEvent
)
{
console
.
log
(
`Monitor on success
${
JSON
.
stringify
(
touchEvent
)}
`
);
return
false
;
}
,
}
;
try
{
inputMonitor
.
on
(
"
touch
"
,
this
.
callback
);
inputMonitor
.
off
(
"
touch
"
,
this
.
callback
);
inputMonitor
.
on
(
"
touch
"
,
callback
);
inputMonitor
.
off
(
"
touch
"
,
callback
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
...
...
@@ -110,13 +111,14 @@ try {
```
js
// 取消监听所有回调函数
callback
:
function
(
touchEvent
)
{
function
callback
(
touchEvent
)
{
console
.
log
(
`Monitor on success
${
JSON
.
stringify
(
touchEvent
)}
`
);
return
false
;
}
,
}
;
try
{
inputMonitor
.
on
(
"
touch
"
,
this
.
callback
);
inputMonitor
.
on
(
"
touch
"
,
callback
);
inputMonitor
.
off
(
"
touch
"
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
...
...
@@ -141,12 +143,14 @@ off(type: "mouse", receiver?: Callback<MouseEvent>): void
```
js
// 取消监听单个回调函数
callback
:
function
(
mouseEvent
)
{
function
callback
(
mouseEvent
)
{
console
.
log
(
`Monitor on success
${
JSON
.
stringify
(
mouseEvent
)}
`
);
},
return
false
;
};
try
{
inputMonitor
.
on
(
"
mouse
"
,
this
.
callback
);
inputMonitor
.
off
(
"
mouse
"
,
this
.
callback
);
inputMonitor
.
on
(
"
mouse
"
,
callback
);
inputMonitor
.
off
(
"
mouse
"
,
callback
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
...
...
@@ -154,12 +158,14 @@ try {
```
js
// 取消监听所有回调函数
callback
:
function
(
mouseEvent
)
{
function
callback
(
mouseEvent
)
{
console
.
log
(
`Monitor on success
${
JSON
.
stringify
(
mouseEvent
)}
`
);
},
return
false
;
};
try
{
inputMonitor
.
on
(
"
mouse
"
,
this
.
callback
);
inputMonitor
.
on
(
"
mouse
"
,
callback
);
inputMonitor
.
off
(
"
mouse
"
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
...
...
zh-cn/application-dev/reference/apis/js-apis-pointer.md
100644 → 100755
浏览文件 @
ec08d637
...
...
@@ -153,7 +153,7 @@ try {
}
console
.
log
(
`Set pointer speed success`
);
});
}
catch
(
err
)
{
}
catch
(
err
or
)
{
console
.
log
(
`Set pointer speed failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
```
...
...
@@ -208,14 +208,14 @@ getPointerSpeed(callback: AsyncCallback<number>): void
```
js
try
{
pointer
.
getPointerSpeed
(
speed
,
(
error
,
speed
)
=>
{
pointer
.
getPointerSpeed
((
error
,
speed
)
=>
{
if
(
error
)
{
console
.
log
(
`Get pointer speed failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
return
;
}
console
.
log
(
`Get pointer speed success, speed:
${
JSON
.
stringify
(
speed
)}
`
);
});
}
catch
(
err
)
{
}
catch
(
err
or
)
{
console
.
log
(
`Get pointer speed failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
```
...
...
@@ -294,6 +294,12 @@ getPointerStyle(windowId: number): Promise<PointerStyle>
**参数**
:
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | -------- |
| windowId | number | 是 | 窗口id。 |
**返回值**
:
| 参数 | 说明 |
| ---------------------------------------- | ------------------- |
| Promise
<
[PointerStyle](#pointerstyle9)
>
| Promise实例,异步返回鼠标样式类型。 |
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录