Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
6a967ff3
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
未验证
提交
6a967ff3
编写于
10月 18, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
!10653 无障碍子系统文档整改
Merge pull request !10653 from zaki/master
上级
be4f6c10
5f96f8fb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
1081 addition
and
343 deletion
+1081
-343
zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePath.md
...n-dev/reference/apis/js-apis-accessibility-GesturePath.md
+49
-0
zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md
...-dev/reference/apis/js-apis-accessibility-GesturePoint.md
+51
-0
zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md
...reference/apis/js-apis-accessibility-extension-context.md
+698
-74
zh-cn/application-dev/reference/apis/js-apis-accessibility.md
...n/application-dev/reference/apis/js-apis-accessibility.md
+277
-229
zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md
...apis/js-apis-application-AccessibilityExtensionAbility.md
+6
-40
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePath.md
0 → 100644
浏览文件 @
6a967ff3
# 手势路径
GesturePath表示手势路径信息。
本模块用于创建辅助功能注入手势所需的手势路径信息。
> **说明:**
>
>本模块首批接口从API version 9开始支持,后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
ts
import
GesturePath
from
"
@ohos.accessibility.GesturePath
"
;
```
## GesturePath
表示手势路径信息。
**系统能力**
:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core
### 属性
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------------ | ---------------------------------------- | ---- | ---- | ------ |
| points | Array
<
[GesturePoint](js-apis-accessibility-GesturePoint.md#gesturepoint)
>
| 是 | 是 | 手势触摸点。 |
| durationTime | number | 是 | 是 | 手势总耗时, 单位为毫秒。 |
### constructor
constructor(durationTime: number);
构造函数。
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| durationTime | number | 是 | 手势总耗时,单位为毫秒。 |
**示例:**
```
typescript
let
durationTime
=
20
;
let
gesturePath
=
new
GesturePath
(
durationTime
);
```
zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md
0 → 100644
浏览文件 @
6a967ff3
# 手势触摸点
GesturePoint表示手势触摸点。
本模块用于创建辅助功能注入手势所需的手势路径的触摸点信息。
> **说明:**
>
>本模块首批接口从API version 9开始支持,后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
ts
import
GesturePoint
from
"
@ohos.accessibility.GesturePoint
"
;
```
## GesturePoint
表示手势触摸点。
**系统能力**
:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core
### 属性
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| --------- | ------ | ---- | ---- | ------- |
| positionX | number | 是 | 是 | 触摸点X坐标。 |
| positionY | number | 是 | 是 | 触摸点Y坐标。 |
### constructor
constructor(positionX: number, positionY: number);
构造函数。
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| positionX | number | 是 | 触摸点X坐标。 |
| positionY | number | 是 | 触摸点Y坐标。 |
**示例:**
```
typescript
let
positionX
=
1
;
let
positionY
=
2
;
let
gesturePoint
=
new
GesturePoint
(
positionX
,
positionY
);
```
zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md
浏览文件 @
6a967ff3
#
AccessibilityExtensionContext
#
辅助功能扩展上下文
AccessibilityExtensionContext是AccessibilityExtensionAbility上下文环境,继承自ExtensionContext。
AccessibilityExtensionContext是AccessibilityExtensionAbility上下文环境,继承自ExtensionContext。
AccessibilityExtensionContext模块提供扩展的上下文
的能力,包括允许配置辅助应用关注信息类型、查询节点信息、手势注入等。
辅助功能扩展上下文模块提供辅助功能扩展的上下文环境
的能力,包括允许配置辅助应用关注信息类型、查询节点信息、手势注入等。
> **说明:**
> **说明:**
>
>
...
@@ -17,7 +17,7 @@ AccessibilityExtensionContext模块提供扩展的上下文的能力,包括允
...
@@ -17,7 +17,7 @@ AccessibilityExtensionContext模块提供扩展的上下文的能力,包括允
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
class
MainAbility
extends
AccessibilityExtensionAbility
{
class
MainAbility
extends
AccessibilityExtensionAbility
{
onConnect
():
void
{
onConnect
():
void
{
console
.
log
(
"
AxExtensionAbility onConnect
"
);
console
.
log
(
'
AxExtensionAbility onConnect
'
);
let
axContext
=
this
.
context
;
let
axContext
=
this
.
context
;
}
}
}
}
...
@@ -77,7 +77,7 @@ class MainAbility extends AccessibilityExtensionAbility {
...
@@ -77,7 +77,7 @@ class MainAbility extends AccessibilityExtensionAbility {
setTargetBundleName(targetNames: Array
\<
string>): Promise
\<
void>;
setTargetBundleName(targetNames: Array
\<
string>): Promise
\<
void>;
设置关注的
事件类型
。
设置关注的
目标包名,使用Promise异步回调
。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
...
@@ -91,19 +91,52 @@ setTargetBundleName(targetNames: Array\<string>): Promise\<void>;
...
@@ -91,19 +91,52 @@ setTargetBundleName(targetNames: Array\<string>): Promise\<void>;
| 类型 | 说明 |
| 类型 | 说明 |
| ---------------------- | --------------------- |
| ---------------------- | --------------------- |
| Promise
<
boolean
>
| Promise对象。返回当前设置是否成功
。 |
| Promise
<
void
>
| 无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
ts
```
ts
this
.
context
.
setTargetBundleName
([
'
com.ohos.mms
'
]);
let
targetNames
=
[
'
com.ohos.xyz
'
];
this
.
context
.
setTargetBundleName
().
then
(()
=>
{
console
.
info
(
'
set target bundle names success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to set target bundle names because
'
+
JSON
.
stringify
(
err
));
});
```
## AccessibilityExtensionContext.setTargetBundleName
setTargetBundleName(targetNames: Array
\<
string>, callback: AsyncCallback
\<
void>): void;
设置关注的目标包名,使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ------------------- | ---- | -------- |
| targetNames | Array
<
string
>
| 是 | 关注的目标包名。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,如果设置关注的目标包名失败,则AsyncCallback中err有数据返回。 |
**示例:**
```
ts
let
targetNames
=
[
'
com.ohos.xyz
'
];
this
.
context
.
setTargetBundleName
().
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to set target bundle names because
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
set target bundle names success
'
);
});
```
```
## AccessibilityExtensionContext.getFocusElement
## AccessibilityExtensionContext.getFocusElement
getFocusElement(isAccessibilityFocus?: boolean): Promise
\<
AccessibilityElement>;
getFocusElement(isAccessibilityFocus?: boolean): Promise
\<
AccessibilityElement>;
获取焦点元素。
获取焦点元素
, 使用Promise异步回调
。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
...
@@ -117,77 +150,296 @@ getFocusElement(isAccessibilityFocus?: boolean): Promise\<AccessibilityElement>;
...
@@ -117,77 +150,296 @@ getFocusElement(isAccessibilityFocus?: boolean): Promise\<AccessibilityElement>;
| 类型 | 说明 |
| 类型 | 说明 |
| ----------------------------------- | ---------------------- |
| ----------------------------------- | ---------------------- |
| Promise
<
AccessibilityElement
>
| Promise对象
。
返回当前对应的焦点元素。 |
| Promise
<
AccessibilityElement
>
| Promise对象
,
返回当前对应的焦点元素。 |
**示例:**
**示例:**
```
ts
```
ts
this
.
context
.
getFocusElement
().
then
(
focusElement
=>
{
let
focusElement
;
console
.
log
(
"
AxExtensionAbility getFocusElement success
"
);
this
.
context
.
getFocusElement
().
then
((
data
)
=>
{
})
focusElement
=
data
;
console
.
log
(
'
get focus element success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get focus element because
'
+
JSON
.
stringify
(
err
));
});
```
```
## AccessibilityExtensionContext.getFocusElement
getFocusElement(callback: AsyncCallback
\<
AccessibilityElement>): void;
获取焦点元素, 使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
AccessibilityElement
>
| 是 | 回调函数,返回当前对应的焦点元素。 |
**示例:**
```
ts
let
focusElement
;
this
.
context
.
getFocusElement
().
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get focus element because
'
+
JSON
.
stringify
(
err
));
return
;
}
focusElement
=
data
;
console
.
info
(
'
get focus element success
'
);
});
```
## AccessibilityExtensionContext.getFocusElement
getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback
\<
AccessibilityElement>): void;
获取焦点元素, 使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------------------- | ------- | ---- | ------------------- |
| isAccessibilityFocus | boolean | 是 | 获取的是否是无障碍焦点元素。 |
| callback | AsyncCallback
<
AccessibilityElement
>
| 是 | 回调函数,返回当前对应的焦点元素。 |
**示例:**
```
ts
let
isAccessibilityFocus
=
true
;
this
.
context
.
getFocusElement
(
isAccessibilityFocus
).
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get focus element because
'
+
JSON
.
stringify
(
err
));
return
;
}
focusElement
=
data
;
console
.
info
(
'
get focus element success
'
);
});
```
## AccessibilityExtensionContext.getWindowRootElement
## AccessibilityExtensionContext.getWindowRootElement
getWindowRootElement(windowId?: number): Promise
\<
AccessibilityElement>;
getWindowRootElement(windowId?: number): Promise
\<
AccessibilityElement>;
获取
窗口的根节点元素
。
获取
指定窗口的根节点元素, 使用Promise异步回调
。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
**参数:**
| 参数名
| 参数类型 | 必填 | 说明
|
| 参数名
| 参数类型 | 必填 | 说明
|
| --------
| ------ | ---- | --------
------------------- |
| --------
------------ | ------- | ---- |
------------------- |
| windowId | number | 否 | 指定
获取根节点元素的窗口
,未指定则从当前活跃窗口获取。 |
| windowId | number | 否 | 指定
窗口的编号
,未指定则从当前活跃窗口获取。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| ----------------------------------- | ----------------------- |
| ----------------------------------- | ---------------------- |
| Promise
<
AccessibilityElement
>
| Promise对象。返回当前对应的根节点元素。 |
| Promise
<
AccessibilityElement
>
| Promise对象,返回指定屏幕的所有窗口。 |
**示例:**
```
ts
let
rootElement
;
this
.
context
.
getWindowRootElement
().
then
((
data
)
=>
{
rootElement
=
data
;
console
.
log
(
'
get root element of the window success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get root element of the window because
'
+
JSON
.
stringify
(
err
));
});
```
## AccessibilityExtensionContext.getWindowRootElement
getWindowRootElement(callback: AsyncCallback
\<
AccessibilityElement>): void;
获取指定窗口的根节点元素, 使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
AccessibilityElement
>
| 是 | 回调函数,返回指定窗口的根节点元素。 |
**示例:**
```
ts
let
rootElement
;
this
.
context
.
getWindowRootElement
().
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get root element of the window because
'
+
JSON
.
stringify
(
err
));
return
;
}
rootElement
=
data
;
console
.
info
(
'
get root element of the window success
'
);
});
```
## AccessibilityExtensionContext.getWindowRootElement
getWindowRootElement(windowId: number, callback: AsyncCallback
\<
AccessibilityElement>): void;
获取指定屏幕中的所有窗口, 使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------------------- | ------- | ---- | ------------------- |
| windowId | number | 是 | 指定窗口的编号,未指定则从当前活跃窗口获取。 |
| callback | AsyncCallback
<
AccessibilityElement
>
| 是 | 回调函数,返回指定窗口的根节点元素。 |
**示例:**
**示例:**
```
ts
```
ts
this
.
context
.
getWindowRootElement
().
then
(
rootElement
=>
{
let
displayId
=
10
;
console
.
log
(
"
AxExtensionAbility getWindowRootElement success
"
);
let
rootElement
;
})
this
.
context
.
getWindowRootElement
(
displayId
).
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get root element of the window because
'
+
JSON
.
stringify
(
err
));
return
;
}
rootElement
=
data
;
console
.
info
(
'
get root element of the window success
'
);
});
```
```
## AccessibilityExtensionContext.getWindows
## AccessibilityExtensionContext.getWindows
getWindows(displayId?: number): Promise
<Array
\<
AccessibilityElement
>
>;
getWindows(displayId?: number): Promise
\
<
Array
\<
AccessibilityElement>>;
获取
用户可见的窗口列表
。
获取
指定屏幕中的所有窗口, 使用Promise异步回调
。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
**参数:**
| 参数名
| 参数类型 | 必填 | 说明
|
| 参数名
| 参数类型 | 必填 | 说明
|
| ---------
| ------ | ---- | ------
------------------- |
| ---------
----------- | ------- | ---- |
------------------- |
| displayId | number | 否 | 指定
获取窗口信息的屏幕
,未指定则从默认主屏幕获取。 |
| displayId | number | 否 | 指定
的屏幕编号
,未指定则从默认主屏幕获取。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| -----------------------------------
----- | --
---------------------- |
| -----------------------------------
|
---------------------- |
| Promise
<
Array
<
AccessibilityElement
>>
| Promise对象
。返回当前对应的窗口列表信息
。 |
| Promise
<
Array
<
AccessibilityElement
>>
| Promise对象
,返回指定屏幕的所有窗口
。 |
**示例:**
**示例:**
```
ts
```
ts
this
.
context
.
getWindows
().
then
(
windows
=>
{
let
windows
;
console
.
log
(
"
AxExtensionAbility getWindows success
"
);
this
.
context
.
getWindows
().
then
((
data
)
=>
{
})
windows
=
data
;
console
.
log
(
'
get windows success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get windows because
'
+
JSON
.
stringify
(
err
));
});
```
## AccessibilityExtensionContext.getWindows
getWindows(callback: AsyncCallback
\<
Array
\<
AccessibilityElement>>): void;
获取指定屏幕中的所有窗口, 使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
Array
<
AccessibilityElement
>>
| 是 | 回调函数,返回指定屏幕的所有窗口。 |
**示例:**
```
ts
let
windows
;
this
.
context
.
getWindows
().
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get windows because
'
+
JSON
.
stringify
(
err
));
return
;
}
windows
=
data
;
console
.
info
(
'
get windows success
'
);
});
```
## AccessibilityExtensionContext.getWindows
getWindows(displayId: number, callback: AsyncCallback
\<
Array
\<
AccessibilityElement>>): void;
获取指定屏幕中的所有窗口, 使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------------------- | ------- | ---- | ------------------- |
| displayId | number | 是 | 指定的屏幕编号,未指定则从默认主屏幕获取。 |
| callback | AsyncCallback
<
Array
<
AccessibilityElement
>>
| 是 | 回调函数,返回指定屏幕的所有窗口。 |
**示例:**
```
ts
let
displayId
=
10
;
let
windows
;
this
.
context
.
getWindows
(
displayId
).
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get windows because
'
+
JSON
.
stringify
(
err
));
return
;
}
windows
=
data
;
console
.
info
(
'
get windows success
'
);
});
```
```
## AccessibilityExtensionContext.injectGesture
## AccessibilityExtensionContext.injectGesture
injectGesture(gesturePath: GesturePath): Promise
\<
void>;
注入手势,使用Promise异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| gesturePath |
[
GesturePath
](
js-apis-accessibility-GesturePath.md#gesturepath
)
| 是 | 表示手势的路径信息。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------- | ---------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**示例:**
```
ts
import
{
GesturePath
}
from
"
../@ohos.accessibility.GesturePath
"
;
let
gesturePath
=
new
GesturePath
(
100
);
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
let
gesturePoint
=
new
GesturePosition
(
100
,
i
*
200
);
gesturePath
.
positions
.
push
(
gesturePoint
);
}
this
.
context
.
gestureInject
(
gesturePath
,
()
=>
{
console
.
info
(
'
inject gesture success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to inject gesture because
'
+
JSON
.
stringify
(
err
));
});
```
## AccessibilityExtensionContext.injectGesture
injectGesture(gesturePath: GesturePath, callback: AsyncCallback
\<
void>): void
injectGesture(gesturePath: GesturePath, callback: AsyncCallback
\<
void>): void
注入手势。
注入手势
,使用callback异步回调
。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
...
@@ -195,8 +447,8 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void
...
@@ -195,8 +447,8 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| ----------- | ---------------------------------------- | ---- | -------------- |
| gesturePath |
[
GesturePath
](
js-apis-a
pplication-AccessibilityExtensionAbility.md#GestureP
ath
)
| 是 | 表示手势的路径信息。 |
| gesturePath |
[
GesturePath
](
js-apis-a
ccessibility-GesturePath.md#gesturep
ath
)
| 是 | 表示手势的路径信息。 |
| callback | AsyncCallback
<
void
>
| 是 | 表示注入手势执行结果的回调。 |
| callback | AsyncCallback
<
void
>
| 是 |
回调函数,
表示注入手势执行结果的回调。 |
**示例:**
**示例:**
...
@@ -206,15 +458,25 @@ for (let i = 0; i < 10; i++) {
...
@@ -206,15 +458,25 @@ for (let i = 0; i < 10; i++) {
let
gesturePoint
=
new
GesturePosition
(
100
,
i
*
200
);
let
gesturePoint
=
new
GesturePosition
(
100
,
i
*
200
);
gesturePath
.
positions
.
push
(
gesturePoint
);
gesturePath
.
positions
.
push
(
gesturePoint
);
}
}
this
.
context
.
gestureInject
(
gesturePath
,
(
result
)
=>
{
this
.
context
.
gestureInject
(
gesturePath
,
(
err
,
data
)
=>
{
console
.
info
(
'
gestureInject result:
'
+
result
);
if
(
err
)
{
})
console
.
error
(
'
failed to inject gesture because
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
inject gesture success
'
);
});
```
```
## AccessibilityElement.attributeNames
## AccessibilityElement<sup>9</sup>
无障碍节点元素。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Core
## attributeNames
attributeNames
\<
T extends keyof ElementAttributeValues>(): Promise
\<
Array
\<
T>>;
attributeNames
\<
T extends keyof ElementAttributeValues>(): Promise
\<
Array
\<
T>>;
获取节点元素的所有属性名称。
获取节点元素的所有属性名称
,使用Promise异步回调
。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
...
@@ -222,28 +484,61 @@ attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>;
...
@@ -222,28 +484,61 @@ attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>;
| 类型 | 说明 |
| 类型 | 说明 |
| ---------------------------------------- | ------------------------ |
| ---------------------------------------- | ------------------------ |
| Promise
<
Array
<
T
>>
| Promise对象
。返回获取元素所有属性名称的调用结果
。 |
| Promise
<
Array
<
T
>>
| Promise对象
,返回节点元素的所有属性名称
。 |
**示例:**
**示例:**
```
ts
```
ts
let
accessibilityElement
;
let
accessibilityElement
;
let
attributeNames
;
try
{
try
{
accessibilityElement
.
attributeNames
().
then
((
values
)
=>
{
accessibilityElement
.
attributeNames
().
then
((
data
)
=>
{
console
.
log
(
"
get attribute names success
"
);
console
.
log
(
'
get attribute names success
'
);
attributeNames
=
data
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
"
get attribute names err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
get attribute names err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
"
An unexpected error occurred. Error:
"
+
e
);
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
}
```
```
## attributeNames
attributeNames
\<
T extends keyof ElementAttributeValues>(callback: AsyncCallback
\<
Array
\<
T>>): void;
获取节点元素的所有属性名称,使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback
<
Array
<
T
>>
| 是 | 回调函数,返回节点元素的所有属性名称。 |
**示例:**
```
ts
let
accessibilityElement
;
let
attributeNames
;
try
{
accessibilityElement
.
attributeNames
().
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get attribute names because
'
+
JSON
.
stringify
(
err
));
return
;
}
attributeNames
=
data
;
console
.
info
(
'
get attribute names success
'
);
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## AccessibilityElement.attributeValue
## AccessibilityElement.attributeValue
attributeValue
\<
T extends keyof ElementAttributeValues>(attributeName: T): Promise
\<
ElementAttributeValues[T]>;
attributeValue
\<
T extends keyof ElementAttributeValues>(attributeName: T): Promise
\<
ElementAttributeValues[T]>;
根据属性名称获取属性值。
根据属性名称获取属性值
,使用Promise异步回调
。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
...
@@ -257,29 +552,65 @@ attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promi
...
@@ -257,29 +552,65 @@ attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promi
| 类型 | 说明 |
| 类型 | 说明 |
| ---------------------------------------- | ------------------------ |
| ---------------------------------------- | ------------------------ |
| Promise
<
Array
<
ElementAttributeValues[T]
>>
| Promise对象。返回根据属性名称获取属性值的调用结果
。 |
| Promise
<
ElementAttributeValues[T]
>
| Promise对象,返回根据节点属性名称获取的属性值
。 |
**示例:**
**示例:**
```
ts
```
ts
let
accessibilityElement
;
let
accessibilityElement
;
let
attributeValue
;
try
{
try
{
let
attributeName
=
'
name
'
;
let
attributeName
=
'
name
'
;
accessibilityElement
.
attributeValue
(
attributeName
).
then
((
value
)
=>
{
accessibilityElement
.
attributeValue
(
attributeName
).
then
((
data
)
=>
{
console
.
log
(
"
get attribute value by name success
"
);
console
.
log
(
'
get attribute value by name success
'
);
attribtueValue
=
data
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
"
get attribute value by name err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
get attribute value by name err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
"
An unexpected error occurred. Error:
"
+
e
);
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
}
```
```
## AccessibilityElement.attributeValue
attributeValue
\<
T extends keyof ElementAttributeValues>(attributeName: T,
callback: AsyncCallback
\<
ElementAttributeValues[T]>): void;
根据属性名称获取属性值,使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| attributeName | T | 是 | 表示属性的名称。 |
| callback | AsyncCallback
<
ElementAttributeValues[T]
>
| 是 | 回调函数,返回根据节点属性名称获取的属性值。 |
**示例:**
## AccessibilityElement.actionNames
```
ts
let
accessibilityElement
;
let
attributeValue
;
try
{
let
attributeName
=
'
name
'
;
accessibilityElement
.
attributeValue
(
attributeName
).
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get attribute value because
'
+
JSON
.
stringify
(
err
));
return
;
}
attributeValue
=
data
;
console
.
info
(
'
get attribute value success
'
);
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## actionNames
actionNames(): Promise
\<
Array
\<
string>>;
actionNames(): Promise
\<
Array
\<
string>>;
获取节点元素支持的所有操作名称。
获取节点元素支持的所有操作名称
,使用Promise异步回调
。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
...
@@ -287,28 +618,61 @@ actionNames(): Promise\<Array\<string>>;
...
@@ -287,28 +618,61 @@ actionNames(): Promise\<Array\<string>>;
| 类型 | 说明 |
| 类型 | 说明 |
| ---------------------------------------- | ------------------------ |
| ---------------------------------------- | ------------------------ |
| Promise
<
Array
<
string
>>
| Promise对象
。返回获取节点元素支持的所有操作名称的调用结果
。 |
| Promise
<
Array
<
string
>>
| Promise对象
,返回节点元素支持的所有操作名称
。 |
**示例:**
**示例:**
```
ts
```
ts
let
accessibilityElement
;
let
accessibilityElement
;
let
actionNames
;
try
{
try
{
accessibilityElement
.
actionNames
().
then
((
values
)
=>
{
accessibilityElement
.
actionNames
().
then
((
data
)
=>
{
console
.
log
(
"
get action names success
"
);
console
.
log
(
'
get action names success
'
);
actionNames
=
data
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
"
get action names err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
get action names err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
"
An unexpected error occurred. Error:
"
+
e
);
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
}
```
```
## actionNames
## AccessibilityElement.performAction
actionNames(callback: AsyncCallback
\<
Array
\<
string>>): void;
获取节点元素支持的所有操作名称,使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback
<
Array
<
string
>>
| 是 | 回调函数,返回节点元素支持的所有操作名称。 |
**示例:**
```
ts
let
accessibilityElement
;
let
actionNames
;
try
{
accessibilityElement
.
actionNames
().
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get action names because
'
+
JSON
.
stringify
(
err
));
return
;
}
actionNames
=
data
;
console
.
info
(
'
get action names success
'
);
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## performAction
performAction(actionName: string, parameters?: object): Promise
\<
boolean>;
performAction(actionName: string, parameters?: object): Promise
\<
boolean>;
根据操作名称执行某个操作。
根据操作名称执行某个操作
,使用Promise异步回调
。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
...
@@ -323,29 +687,139 @@ performAction(actionName: string, parameters?: object): Promise\<boolean>;
...
@@ -323,29 +687,139 @@ performAction(actionName: string, parameters?: object): Promise\<boolean>;
| 类型 | 说明 |
| 类型 | 说明 |
| ---------------------------------------- | ------------------------ |
| ---------------------------------------- | ------------------------ |
| Promise
<
Array
<
boolean
>>
| Promise对象。返回获取元素所有属性名的调用结果
。 |
| Promise
<
boolean
>
| Promise对象,返回执行指定操作后的回调结果,true为执行成功,false为执行失败
。 |
**示例:**
**示例:**
```
ts
```
ts
let
accessibilityElement
;
let
accessibilityElement
;
let
performActionRes
;
try
{
try
{
accessibilityElement
.
performAction
(
'
action
'
).
then
((
data
)
=>
{
accessibilityElement
.
performAction
(
'
action
'
).
then
((
result
)
=>
{
console
.
info
(
'
perform action success
'
);
console
.
info
(
'
perform action result:
'
+
result
)
;
performActionRes
=
data
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
"
perform action err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
failed to perform action because
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
"
An unexpected error occurred. Error:
"
+
e
);
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
}
```
```
## performAction
performAction(actionName: string, callback: AsyncCallback
\<
boolean>): void;
根据操作名称执行某个操作,使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
## AccessibilityElement.findElement
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| actionName | string | 是 | 表示属性的名称。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数,返回执行指定操作后的回调结果,true为执行成功,false为执行失败。 |
**示例:**
```
ts
let
accessibilityElement
;
let
performActionRes
;
try
{
accessibilityElement
.
performAction
(
'
action
'
).
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to perform action because
'
+
JSON
.
stringify
(
err
));
return
;
}
performActionRes
=
data
;
console
.
info
(
'
perform action success
'
);
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## performAction
performAction(actionName: string, parameters: object, callback: AsyncCallback
\<
boolean>): void;
根据操作名称执行某个操作,使用callback异步回调。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| actionName | string | 是 | 表示属性的名称。 |
| parameters | object | 是 | 表示执行操作时所需要的参数。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数,返回执行指定操作后的回调结果,true为执行成功,false为执行失败。 |
**示例:**
```
ts
let
accessibilityElement
;
let
actionName
=
'
action
'
;
let
parameters
=
{
'
setText
'
:
'
test text
'
};
let
performActionRes
;
try
{
accessibilityElement
.
performAction
(
actionName
,
parameters
).
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to perform action because
'
+
JSON
.
stringify
(
err
));
return
;
}
performActionRes
=
data
;
console
.
info
(
'
perform action success
'
);
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## findElement('content')
findElement(type: 'content', condition: string): Promise
\<
Array
\<
AccessibilityElement>>;
findElement(type: 'content', condition: string): Promise
\<
Array
\<
AccessibilityElement>>;
查询节点元素的指定内容。
根据节点内容查询所有节点元素。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| type | string | 是 | 固定为'content', 表示查找的类型为节点元素内容。 |
| condition | string | 是 | 表示查找的条件。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------------- | ------------------------ |
| Promise
<
Array
<
AccessibilityElement
>>
| Promise对象,返回满足指定查询关键字的所有节点元素。 |
**示例:**
```
ts
let
accessibilityElement
;
let
type
=
'
content
'
;
let
condition
=
'
keyword
'
;
let
elements
;
try
{
accessibilityElement
.
findElement
(
type
,
condition
).
then
((
data
)
=>
{
elements
=
data
;
console
.
log
(
'
find element success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to find element because
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## findElement('content')
findElement(type: 'content', condition: string, callback: AsyncCallback
\<
Array
\<
AccessibilityElement>>): void;
根据节点内容查询所有节点元素。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
...
@@ -355,25 +829,175 @@ findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityEl
...
@@ -355,25 +829,175 @@ findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityEl
| ----------- | ---------------------------------------- | ---- | -------------- |
| ----------- | ---------------------------------------- | ---- | -------------- |
| type | string | 是 | 固定为'content',表示查找的类型为节点元素内容。 |
| type | string | 是 | 固定为'content',表示查找的类型为节点元素内容。 |
| condition | string | 是 | 表示查找的条件。 |
| condition | string | 是 | 表示查找的条件。 |
| callback | AsyncCallback
<
Array
<
AccessibilityElement
>>
| 是 | 回调函数,返回满足指定查询关键字的所有节点元素。 |
**示例:**
```
ts
let
accessibilityElement
;
let
type
=
'
content
'
;
let
condition
=
'
keyword
'
;
let
elements
;
try
{
accessibilityElement
.
findElement
(
type
,
condition
).
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to find element because
'
+
JSON
.
stringify
(
err
));
return
;
}
elements
=
data
;
console
.
info
(
'
find element success
'
);
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## findElement('focusType')
findElement(type: 'focusType', condition: FocusType): Promise
\<
AccessibilityElement>;
根据焦点元素类型查询节点元素。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| type | string | 是 | 固定为'focusType', 表示查询的类型为节点的焦点元素类型。 |
| condition |
[
FocusType
](
#focustype
)
| 是 | 表示查询焦点元素的类型。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| ---------------------------------------- | ------------------------ |
| ---------------------------------------- | ------------------------ |
| Promise
<
A
rray
<
T
>>
| Promise对象。返回获取元素所有属性名的调用结果
。 |
| Promise
<
A
ccessibilityElement
>
| Promise对象,返回满足指定查询焦点元素类型的节点元素
。 |
**示例:**
**示例:**
```
ts
```
ts
let
accessibilityElement
;
let
accessibilityElement
;
let
type
=
'
focusType
'
;
let
condition
=
'
normal
'
;
let
elements
;
try
{
try
{
let
condition
=
'
keyword
'
;
accessibilityElement
.
findElement
(
type
,
condition
).
then
((
data
)
=>
{
accessibilityElement
.
findElement
(
'
content
'
,
condition
).
then
((
values
)
=>
{
elements
=
data
;
console
.
log
(
"
find element success
"
);
console
.
log
(
'
find element success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
"
find element err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
failed to find element because
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## findElement('focusType')
findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback
\<
AccessibilityElement>): void;
根据焦点元素类型查询节点元素。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| type | string | 是 | 固定为'focusType', 表示查询的类型为节点的焦点元素类型。 |
| condition |
[
FocusType
](
#focustype
)
| 是 | 表示查询焦点元素的类型。 |
| callback | AsyncCallback
<
AccessibilityElement
>
| 是 | 回调函数,返回满足指定查询焦点元素类型的节点元素。 |
**示例:**
```
ts
let
accessibilityElement
;
let
type
=
'
focusType
'
;
let
condition
=
'
normal
'
;
let
elements
;
try
{
accessibilityElement
.
findElement
(
type
,
condition
).
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to find element because
'
+
JSON
.
stringify
(
err
));
return
;
}
elements
=
data
;
console
.
info
(
'
find element success
'
);
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection): Promise
\<
AccessibilityElement>;
根据下一焦点元素方向查询节点元素。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| type | string | 是 | 固定为'focusDirection', 表示查询的类型为节点的下一焦点元素方向。 |
| condition |
[
FocusDirection
](
#focusdirection
)
| 是 | 表示查询下一焦点元素的方向。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------------- | ------------------------ |
| Promise
<
AccessibilityElement
>
| Promise对象,返回满足指定查询下一焦点元素方向的节点元素。 |
**示例:**
```
ts
let
accessibilityElement
;
let
type
=
'
focusDirection
'
;
let
condition
=
'
up
'
;
let
elements
;
try
{
accessibilityElement
.
findElement
(
type
,
condition
).
then
((
data
)
=>
{
elements
=
data
;
console
.
log
(
'
find element success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to find element because
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
e
)
{
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
```
## findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback
\<
AccessibilityElement>): void;
根据下一焦点元素方向查询所有节点元素。
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | -------------- |
| type | string | 是 | 固定为'focusDirection', 表示查询的类型为节点的下一焦点元素方向。 |
| condition |
[
FocusDirection
](
#focusdirection
)
| 是 | 表示下一查询焦点元素的方向。 |
| callback | AsyncCallback
<
AccessibilityElement
>
| 是 | 回调函数,返回满足指定查询下一焦点元素方向的节点元素。 |
**示例:**
```
ts
let
accessibilityElement
;
let
type
=
'
focusDirection
'
;
let
condition
=
'
up
'
;
let
elements
;
try
{
accessibilityElement
.
findElement
(
type
,
condition
).
then
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to find element because
'
+
JSON
.
stringify
(
err
));
return
;
}
elements
=
data
;
console
.
info
(
'
find element success
'
);
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
"
An unexpected error occurred. Error:
"
+
e
);
console
.
log
(
'
An unexpected error occurred. Error:
'
+
e
);
}
}
```
```
zh-cn/application-dev/reference/apis/js-apis-accessibility.md
浏览文件 @
6a967ff3
...
@@ -144,7 +144,7 @@ import accessibility from '@ohos.accessibility';
...
@@ -144,7 +144,7 @@ import accessibility from '@ohos.accessibility';
## CaptionsManager<sup>8+</sup>
## CaptionsManager<sup>8+</sup>
字幕配置。
字幕配置
管理,在调用CaptionsManager的方法前,需要先通过
[
accessibility.getCaptionsManager()
](
#accessibilitygetcaptionsmanager8
)
获取 captionsManager实例
。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Hearing
**系统能力**
:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Hearing
...
@@ -155,90 +155,92 @@ import accessibility from '@ohos.accessibility';
...
@@ -155,90 +155,92 @@ import accessibility from '@ohos.accessibility';
| enabled | boolean | 是 | 否 | 表示是否启用字幕配置。 |
| enabled | boolean | 是 | 否 | 表示是否启用字幕配置。 |
| style |
[
CaptionsStyle
](
#captionsstyle8
)
| 是 | 否 | 表示字幕风格。 |
| style |
[
CaptionsStyle
](
#captionsstyle8
)
| 是 | 否 | 表示字幕风格。 |
下列 API 示例中都需要使用
[
accessibility.getCaptionsManager()
](
#accessibilitygetcaptionsmanager8
)
获取 captionsManager 实例,再通过此实例调用对应的方法。
### on('enableChange')
### on('enableChange')
on(type: 'enableChange', callback: Callback
<
boolean
>
): void;
on(type: 'enableChange', callback: Callback
<
boolean
>
): void;
注册字幕配置启用的监听函数
。
监听字幕配置启用状态变化事件
。
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听字幕配置启用状态
。 |
| type | string | 是 | 监听的事件名,固定为‘enableChange’,即字幕配置启用状态变化事件
。 |
| callback | Callback
<
boolean
>
| 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 |
| callback | Callback
<
boolean
>
| 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
let
captionsManager
=
accessibility
.
getCaptionsManager
();
let
captionsManager
=
accessibility
.
getCaptionsManager
();
captionsManager
.
on
(
'
enableChange
'
,(
data
)
=>
{
captionsManager
.
on
(
'
enableChange
'
,(
data
)
=>
{
console
.
info
(
'
success data:subscribeStateObserver :
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
success data:subscribeStateObserver :
'
+
JSON
.
stringify
(
data
))
})
})
;
```
```
### on('styleChange')
### on('styleChange')
on(type: 'styleChange', callback: Callback
<
CaptionsStyle
>
): void;
on(type: 'styleChange', callback: Callback
<
CaptionsStyle
>
): void;
注册字幕风格变化的监听函数
。
监听字幕风格变化事件
。
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听字幕风格变化
。 |
| type | string | 是 | 监听的事件名,固定为‘styleChange’,即字幕风格变化事件
。 |
| callback | Callback
<
[CaptionsStyle](#captionsstyle8)
>
| 是 | 回调函数,在字幕风格变化时通过此函数进行通知。 |
| callback | Callback
<
[CaptionsStyle](#captionsstyle8)
>
| 是 | 回调函数,在字幕风格变化时通过此函数进行通知。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
let
captionsManager
=
accessibility
.
getCaptionsManager
();
let
captionsManager
=
accessibility
.
getCaptionsManager
();
captionsManager
.
on
(
'
styleChange
'
,(
data
)
=>
{
captionsManager
.
on
(
'
styleChange
'
,(
data
)
=>
{
console
.
info
(
'
success data:subscribeStateObserver :
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
success data:subscribeStateObserver :
'
+
JSON
.
stringify
(
data
))
})
})
;
```
```
### off('enableChange')
### off('enableChange')
off(type: 'enableChange', callback?: Callback
<
boolean
>
): void;
off(type: 'enableChange', callback?: Callback
<
boolean
>
): void;
移除字幕配置启用的监听函数
。
取消监听字幕配置启用状态变化事件
。
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听字幕配置启用状态
。 |
| type | string | 是 | 取消监听的事件名,固定为‘enableChange’,即字幕配置启用状态变化事件
。 |
| callback | Callback
<
boolean
>
| 否 | 回调函数,在
启用状态变化时将状态通过此函数进行通知。 |
| callback | Callback
<
boolean
>
| 否 | 回调函数,在字幕配置
启用状态变化时将状态通过此函数进行通知。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
let
captionsManager
=
accessibility
.
getCaptionsManager
();
let
captionsManager
=
accessibility
.
getCaptionsManager
();
captionsManager
.
off
(
'
enableChange
'
)
captionsManager
.
off
(
'
enableChange
'
,(
data
)
=>
{
console
.
info
(
'
success data:unSubscribeStateObserver :
'
+
JSON
.
stringify
(
data
))
});
```
```
### off('styleChange')
### off('styleChange')
off(type: 'styleChange', callback?: Callback
<
CaptionsStyle
>
): void;
off(type: 'styleChange', callback?: Callback
<
CaptionsStyle
>
): void;
移除字幕风格变化的监听函数
。
取消字幕风格变化监听事件
。
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 字幕风格变化
。 |
| type | string | 是 | 取消监听的事件名,固定为‘styleChange’,即字幕风格变化事件
。 |
| callback | Callback
<
[CaptionsStyle](#captionsstyle8)
>
| 否 | 回调函数,在字幕风格变化时通过此函数进行通知。 |
| callback | Callback
<
[CaptionsStyle](#captionsstyle8)
>
| 否 | 回调函数,在字幕风格变化时通过此函数进行通知。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
let
captionsManager
=
accessibility
.
getCaptionsManager
();
let
captionsManager
=
accessibility
.
getCaptionsManager
();
captionsManager
.
off
(
'
styleChange
'
)
captionsManager
.
off
(
'
styleChange
'
,(
data
)
=>
{
console
.
info
(
'
success data:unSubscribeStateObserver :
'
+
JSON
.
stringify
(
data
))
});
```
```
## EventInfo
## EventInfo
...
@@ -274,16 +276,20 @@ constructor(jsonObject)
...
@@ -274,16 +276,20 @@ constructor(jsonObject)
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| jsonObject | string | 是 | 创建对象所需要的 JSON 格式字符串。 |
| jsonObject | string | 是 | 创建对象所需要的 JSON 格式字符串。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
let
eventInfo
=
new
accessibility
.
EventInfo
({
"
type
"
:
"
click
"
,
"
bundleName
"
:
"
com.example.MyApplication
"
,
"
triggerAction
"
:
"
click
"
})
let
eventInfo
=
new
accessibility
.
EventInfo
({
"
type
"
:
"
click
"
,
"
bundleName
"
:
"
com.example.MyApplication
"
,
"
triggerAction
"
:
"
click
"
});
```
```
## EventType
## EventType
...
@@ -338,306 +344,348 @@ constructor(jsonObject)
...
@@ -338,306 +344,348 @@ constructor(jsonObject)
getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise
<
Array
<
AccessibilityAbilityInfo
>>
getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise
<
Array
<
AccessibilityAbilityInfo
>>
查询辅助应用列表。
查询辅助应用列表
,使用Promise异步回调
。
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| abilityType |
[
AbilityType
](
#abilitytype
)
| 是 | 辅助应用的类型。 |
| abilityType |
[
AbilityType
](
#abilitytype
)
| 是 | 辅助应用的类型。 |
| stateType |
[
AbilityState
](
#abilitystate
)
| 是 | 辅助应用的状态。 |
| stateType |
[
AbilityState
](
#abilitystate
)
| 是 | 辅助应用的状态。 |
-
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
| Promise
<
Array
<
[AccessibilityAbilityInfo](#accessibilityabilityinfo)
>>
|
返回辅助应用信息列表。 |
| Promise
<
Array
<
[AccessibilityAbilityInfo](#accessibilityabilityinfo)
>>
| Promise对象,
返回辅助应用信息列表。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
accessibility
.
getAbilityLists
(
"
spoken
"
,
"
enable
"
)
accessibility
.
getAbilityLists
(
"
spoken
"
,
"
enable
"
).
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
success data:getAbilityList1 :
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
success data:getAbilityList1 :
'
+
JSON
.
stringify
(
data
));
for
(
let
item
of
data
)
{
for
(
let
item
of
data
)
{
console
.
info
(
item
.
id
);
console
.
info
(
item
.
id
);
console
.
info
(
item
.
name
);
console
.
info
(
item
.
name
);
console
.
info
(
item
.
description
);
console
.
info
(
item
.
description
);
console
.
info
(
item
.
bundleName
);
console
.
info
(
item
.
bundleName
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
error
)
=>
{
console
.
error
(
'
failed to getAbilityList1 because
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
failed to getAbilityList1 because
'
+
JSON
.
stringify
(
error
));
});
})
```
```
## accessibility.getAbilityLists
## accessibility.getAbilityLists
getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback
<
Array
<
AccessibilityAbilityInfo
>>
): void
getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback
<
Array
<
AccessibilityAbilityInfo
>>
): void
查询辅助应用列表。
查询辅助应用列表
,使用callback异步回调
。
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| abilityType |
[
AbilityType
](
#abilitytype
)
| 是 | 辅助应用的类型。 |
| abilityType |
[
AbilityType
](
#abilitytype
)
| 是 | 辅助应用的类型。 |
| stateType |
[
AbilityState
](
#abilitystate
)
| 是 | 辅助应用的状态。 |
| stateType |
[
AbilityState
](
#abilitystate
)
| 是 | 辅助应用的状态。 |
| callback | AsyncCallback
<
Array
<
[AccessibilityAbilityInfo](#accessibilityabilityinfo)
>>
| 是 | 回调函数,返回辅助应用信息列表。 |
| callback | AsyncCallback
<
Array
<
[AccessibilityAbilityInfo](#accessibilityabilityinfo)
>>
| 是 | 回调函数,返回辅助应用信息列表。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
accessibility
.
getAbilityLists
(
"
visual
"
,
"
enable
"
,
(
err
,
data
)
=>
{
accessibility
.
getAbilityLists
(
"
visual
"
,
"
enable
"
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
failed to getAbilityList2 because
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
failed to getAbilityList2 because
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
success data:getAbilityList2 :
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
success data:getAbilityList2 :
'
+
JSON
.
stringify
(
data
));
for
(
let
item
of
data
)
{
for
(
let
item
of
data
)
{
console
.
info
(
item
.
id
);
console
.
info
(
item
.
id
);
console
.
info
(
item
.
name
);
console
.
info
(
item
.
name
);
console
.
info
(
item
.
description
);
console
.
info
(
item
.
description
);
console
.
info
(
item
.
bundleName
);
console
.
info
(
item
.
bundleName
);
}
}
})
});
```
```
## accessibility.getCaptionsManager<sup>8+</sup>
## accessibility.getCaptionsManager<sup>8+</sup>
getCaptionsManager(): CaptionsManager
getCaptionsManager(): CaptionsManager
获取无障碍字幕配置。
获取无障碍字幕配置
管理实例
。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Hearing
**系统能力**:SystemCapability.BarrierFree.Accessibility.Hearing
-
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
[
CaptionsManager
](
#captionsmanager8
)
| 无障碍字幕配置管理。 |
| [CaptionsManager](#captionsmanager8) | 无障碍字幕配置管理。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
let
captionsManager
=
accessibility
.
getCaptionsManager
()
let captionsManager = accessibility.getCaptionsManager();
```
```
## accessibility.on('accessibilityStateChange'
| 'touchGuideStateChange'
)
## accessibility.on('accessibilityStateChange')
on(type: 'accessibilityStateChange'
| 'touchGuideStateChange'
, callback: Callback
<
boolean
>
): void
on(type: 'accessibilityStateChange', callback: Callback<boolean>): void
启用辅助应用和触摸浏览功能的状态变化监听
。
监听辅助应用启用状态变化事件
。
**系统能力**:以下各项对应的系统能力有所不同,详见下表。
**系统能力**:以下各项对应的系统能力有所不同,详见下表。
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听的事件类型。
<br/>
-
type 为'accessibilityStateChange'时表示监听类型为辅助功能启用状态变化监听;
<br/>
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
<br/>
-
type 为'touchGuideStateChange'时表示监听类型为触摸浏览启用状态变化监听。
<br/>
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Vision
|
| type | string | 是 | 监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。
|
| callback | Callback
<
boolean
>
| 是 | 回调函数,在
启用状态变化时将状态通过此函数进行通知。 |
| callback | Callback<boolean> | 是 | 回调函数,在辅助应用
启用状态变化时将状态通过此函数进行通知。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
accessibility
.
on
(
'
accessibilityStateChange
'
,(
data
)
=>
{
accessibility.on('accessibilityStateChange',(data) => {
console
.
info
(
'
success data:subscribeStateObserver :
'
+
JSON
.
stringify
(
data
))
console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
})
});
```
```
## accessibility.o
ff('accessibilityStateChange' |
'touchGuideStateChange')
## accessibility.o
n(
'touchGuideStateChange')
o
ff(type: ‘accessibilityStateChange ’ | ‘touchGuideStateChange’, callback?
: Callback
<
boolean
>
): void
o
n(type: 'touchGuideStateChange', callback
: Callback<boolean>): void
关闭辅助应用和触摸浏览功能的状态变化监听
。
监听触摸浏览功能启用状态变化事件
。
**系统能力**:以下各项对应的系统能力有所不同,详见下表。
**系统能力**:以下各项对应的系统能力有所不同,详见下表。
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 否 | 监听的事件类型。
<br/>
-
type 为'accessibilityStateChange'时表示监听类型为辅助功能启用状态变化监听;
<br/>
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Core
<br/>
-
type 为'touchGuideStateChange'时表示监听类型为触摸浏览启用状态变化监听。
<br/>
**系统能力**
:SystemCapability.BarrierFree.Accessibility.Vision
|
| type | string | 是 | 监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。
|
| callback | Callback
<
boolean
>
| 否 | 要取消的监听回调函数
。 |
| callback | Callback<boolean> | 是 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知
。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
accessibility
.
off
(
'
accessibilityStateChange
'
,(
data
)
=>
{
accessibility.on('touchGuideStateChange',(data) => {
console
.
info
(
'
success data:unSubscribeStateObserver :
'
+
JSON
.
stringify
(
data
))
console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
})
});
```
```
## accessibility.off('accessibilityStateChange')
off(type: 'accessibilityStateChange', callback?: Callback<boolean>): void
取消监听辅助应用启用状态变化事件。
**系统能力**:以下各项对应的系统能力有所不同,详见下表。
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 否 | 取消监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 |
| callback | Callback<boolean> | 否 | 回调函数,在辅助应用启用状态变化时将状态通过此函数进行通知。 |
**示例:**
```
typescript
accessibility.off('accessibilityStateChange',(data) => {
console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data))
});
```
## accessibility.off('touchGuideStateChange')
off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void
取消监听触摸浏览启用状态变化事件。
**系统能力**:以下各项对应的系统能力有所不同,详见下表。
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 否 | 取消监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 |
| callback | Callback<boolean> | 否 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知。 |
**示例:**
```
typescript
accessibility.off('touchGuideStateChange',(data) => {
console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data))
});
```
## accessibility.isOpenAccessibility
## accessibility.isOpenAccessibility
isOpenAccessibility(): Promise<boolean>
isOpenAccessibility(): Promise<boolean>
判断是否启用了辅助功能。
判断是否启用了辅助功能
, 使用Promise异步回调
。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
-
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
| Promise
<
boolean
>
|
如果辅助功能已启用,则返回 true;否则返回 false。 |
| Promise<boolean> | Promise对象,
如果辅助功能已启用,则返回 true;否则返回 false。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
accessibility
.
isOpenAccessibility
()
accessibility.isOpenAccessibility().then((data) => {
.
then
((
data
)
=>
{
console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
console
.
info
(
'
success data:isOpenAccessibility :
'
+
JSON
.
stringify
(
data
))
}).catch((err) => {
}).
catch
((
error
)
=>
{
console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
console
.
error
(
'
failed to isOpenAccessibility because
'
+
JSON
.
stringify
(
error
));
});
})
```
```
## accessibility.isOpenAccessibility
## accessibility.isOpenAccessibility
isOpenAccessibility(callback: AsyncCallback<boolean>): void
isOpenAccessibility(callback: AsyncCallback<boolean>): void
判断是否启用了辅助功能。
判断是否启用了辅助功能
,使用callback异步回调
。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数,如果辅助功能已启用,则返回 true;否则返回 false。 |
| callback | AsyncCallback<boolean> | 是 | 回调函数,如果辅助功能已启用,则返回 true;否则返回 false。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
accessibility
.
isOpenAccessibility
((
err
,
data
)
=>
{
accessibility.isOpenAccessibility((err, data) => {
if
(
err
)
{
if (err) {
console
.
error
(
'
failed to isOpenAccessibility because
'
+
JSON
.
stringify
(
err
));
console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
return
;
return;
}
}
console
.
info
(
'
success data:isOpenAccessibility :
'
+
JSON
.
stringify
(
data
))
console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
})
});
```
```
## accessibility.isOpenTouchGuide
## accessibility.isOpenTouchGuide
isOpenTouchGuide(): Promise<boolean>
isOpenTouchGuide(): Promise<boolean>
判断触摸浏览模式是否开启。
判断触摸浏览模式是否开启
, 使用Promise异步回调
。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Vision
**系统能力**:SystemCapability.BarrierFree.Accessibility.Vision
-
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
| Promise
<
boolean
>
|
如果触摸浏览模式已开启,则返回 true;否则返回 false。 |
| Promise<boolean> | Promise对象,
如果触摸浏览模式已开启,则返回 true;否则返回 false。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
accessibility
.
isOpenTouchGuide
()
accessibility.isOpenTouchGuide().then((data) => {
.
then
((
data
)
=>
{
console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
console
.
info
(
'
success data:isOpenTouchGuide :
'
+
JSON
.
stringify
(
data
))
}).catch((err) => {
}).
catch
((
error
)
=>
{
console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
console
.
error
(
'
failed to isOpenTouchGuide because
'
+
JSON
.
stringify
(
error
));
});
})
```
```
## accessibility.isOpenTouchGuide
## accessibility.isOpenTouchGuide
isOpenTouchGuide(callback: AsyncCallback<boolean>): void
isOpenTouchGuide(callback: AsyncCallback<boolean>): void
判断触摸浏览模式是否开启。
判断触摸浏览模式是否开启
, 使用callback异步回调
。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Vision
**系统能力**:SystemCapability.BarrierFree.Accessibility.Vision
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数,如果触摸浏览模式已开启,则返回 true;否则返回 false。 |
| callback | AsyncCallback<boolean> | 是 | 回调函数,如果触摸浏览模式已开启,则返回 true;否则返回 false。 |
-
**示例:**
**示例:**
```
typescript
```
typescript
accessibility
.
isOpenTouchGuide
((
err
,
data
)
=>
{
accessibility.isOpenTouchGuide((err, data) => {
if
(
err
)
{
if (err) {
console
.
error
(
'
failed to isOpenTouchGuide because
'
+
JSON
.
stringify
(
err
));
console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
return
;
return;
}
}
console
.
info
(
'
success data:isOpenTouchGuide :
'
+
JSON
.
stringify
(
data
))
console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
})
});
```
```
## accessibility.sendEvent
## accessibility.sendEvent
sendEvent(event: EventInfo): Promise<void>
sendEvent(event: EventInfo): Promise<void>
发送无障碍事件。
发送无障碍事件
, 使用Promise异步回调
。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| event |
[
EventInfo
](
#eventinfo
)
| 是 | 无障碍事件对象。 |
| event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 |
-
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
| Promise
<
void
>
| 以 Promise 形式返回结果,如果发送无障碍事件成功,则 data 有数据返回;如果发送无障碍事件失败,则 err 有数据返回
。 |
| Promise<void> | 无返回结果的Promise对象
。 |
-
**示例:**
**示例:**
```
typescript
```typescript
let
eventInfo
:
accessibility
.
EventInfo
=
{
let eventInfo = new accessibility.EventInfo({
type
:
'
focus
'
,
"type":"click",
bundleName
:
'
bundle
'
,
"bundleName":"com.example.MyApplication",
triggerAction
:
'
focus
'
"triggerAction":"click"
}
});
accessibility
.
sendEvent
(
eventInfo
)
accessibility.sendEvent(eventInfo).then(() => {
.
then
((
data
)
=>
{
console.info('send event success');
console
.
info
(
'
success data:sendEvent :
'
+
JSON
.
stringify
(
data
))
}).catch((err) => {
}).
catch
((
error
)
=>
{
console.error('failed to sendEvent because ' + JSON.stringify(err));
console
.
error
(
'
failed to sendEvent because
'
+
JSON
.
stringify
(
error
));
});
})
```
```
## accessibility.sendEvent
## accessibility.sendEvent
sendEvent(event: EventInfo, callback: AsyncCallback<void>): void
sendEvent(event: EventInfo, callback: AsyncCallback<void>): void
发送无障碍事件。
发送无障碍事件
, 使用callback异步回调
。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
-
**参数:**
**参数:**
| 参数名 | 参数类型 | 必填 | 说明 |
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| event |
[
EventInfo
](
#eventinfo
)
| 是 | 辅助事件对象。 |
| event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,如果发送无障碍事件成功,则 AsyncCallback 中 data 有数据返回;如果发送无障碍事件失败,则 AsyncCallback 中 err
有数据返回。 |
| callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件失败,则 AsyncCallback中err
有数据返回。 |
-
**示例:**
**示例:**
```
typescript
```typescript
let
eventInfo
:
accessibility
.
EventInfo
=
{
let eventInfo = new accessibility.EventInfo(
{
type
:
'
focus
'
,
"type":"click"
,
bundleName
:
'
bundle
'
,
"bundleName":"com.example.MyApplication"
,
triggerAction
:
'
focus
'
"triggerAction":"click"
}
});
accessibility
.
sendEvent
(
eventInfo
,
(
err
,
data
)
=>
{
accessibility.sendEvent(eventInfo,
(err, data) => {
if
(
err
)
{
if (err) {
console
.
error
(
'
failed to sendEvent because
'
+
JSON
.
stringify
(
err
));
console.error('failed to sendEvent because ' + JSON.stringify(err));
return
;
return;
}
}
console
.
info
(
'
success data:sendEvent :
'
+
JSON
.
stringify
(
data
))
console.info('sendEvent success');
})
});
```
```
zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md
浏览文件 @
6a967ff3
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
**AccessibilityExtensionAbility**
基于ExtensionAbility框架,提供辅助功能业务的能力。
**AccessibilityExtensionAbility**
基于ExtensionAbility框架,提供辅助功能业务的能力。
>**说明:**
>

**说明:**
>
>
>本模块首批接口从API version 9开始支持,后续版本的新增接口,采用上角标单独标记接口的起始版本。
>本模块首批接口从API version 9开始支持,后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
>
...
@@ -32,36 +32,10 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens
...
@@ -32,36 +32,10 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| --------- | ---------------------------------------- | ---- | ---- | ---------- |
| --------- | ---------------------------------------- | ---- | ---- | ---------- |
| eventType |
[
EventType
](
js-apis-accessibility.md#EventType
)
\|
[
WindowUpdateType
](
js-apis-accessibility.md#WindowUpdateType
)
\|
[
TouchGuideType
](
touchguidetype
)
\|
[
GestureType
](
gesturetype
)
\|
[
PageUpdateType
](
pageupdatetype
)
| 是 | 否 | 具体事件类型。 |
| eventType |
[
EventType
](
js-apis-accessibility.md#EventType
)
\|
[
WindowUpdateType
](
js-apis-accessibility.md#WindowUpdateType
)
\|
[
TouchGuideType
](
#touchguidetype
)
\|
[
GestureType
](
#gesturetype
)
\|
[
PageUpdateType
](
#
pageupdatetype
)
| 是 | 否 | 具体事件类型。 |
| target | AccessibilityElement | 是 | 否 | 发生事件的目标组件。 |
| target | AccessibilityElement | 是 | 否 | 发生事件的目标组件。 |
| timeStamp | number | 是 | 否 | 事件时间戳。 |
| timeStamp | number | 是 | 否 | 事件时间戳。 |
## GesturePath
表示手势路径信息。
**系统能力**
:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core
### 属性
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------------ | ---------------------------------------- | ---- | ---- | ------ |
| points | Array
<
[GesturePoint](gesturepoint)
>
| 是 | 是 | 手势。 |
| durationTime | number | 是 | 是 | 手势总耗时。 |
## GesturePoint
表示手势触摸点。
**系统能力**
:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core
### 属性
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| --------- | ------ | ---- | ---- | ------- |
| positionX | number | 是 | 是 | 触摸点X坐标。 |
| positionY | number | 是 | 是 | 触摸点Y坐标。 |
## GestureType
## GestureType
手势事件类型。
手势事件类型。
...
@@ -117,16 +91,12 @@ onConnect(): void;
...
@@ -117,16 +91,12 @@ onConnect(): void;
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
无
**示例:**
**示例:**
```
ts
```
ts
onConnect
():
void
{
onConnect
():
void
{
console
.
log
(
"
AxExtensionAbility onConnect
"
);
console
.
log
(
"
AxExtensionAbility onConnect
"
);
}
}
;
```
```
## AccessibilityExtensionAbility.onDisconnect
## AccessibilityExtensionAbility.onDisconnect
...
@@ -137,16 +107,12 @@ onDisconnect(): void;
...
@@ -137,16 +107,12 @@ onDisconnect(): void;
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**系统能力:**
SystemCapability.BarrierFree.Accessibility.Core
**参数:**
无
**示例:**
**示例:**
```
ts
```
ts
onDisconnect
():
void
{
onDisconnect
():
void
{
console
.
log
(
"
AxExtensionAbility onDisconnect
"
);
console
.
log
(
"
AxExtensionAbility onDisconnect
"
);
}
}
;
```
```
## AccessibilityExtensionAbility.onAccessibilityEvent
## AccessibilityExtensionAbility.onAccessibilityEvent
...
@@ -171,7 +137,7 @@ onAccessibilityEvent(event: AccessibilityEvent): void {
...
@@ -171,7 +137,7 @@ onAccessibilityEvent(event: AccessibilityEvent): void {
if
(
event
.
eventType
==
'
click
'
)
{
if
(
event
.
eventType
==
'
click
'
)
{
console
.
log
(
"
AxExtensionAbility onAccessibilityEvent: click
"
);
console
.
log
(
"
AxExtensionAbility onAccessibilityEvent: click
"
);
}
}
}
}
;
```
```
## AccessibilityExtensionAbility.onKeyEvent
## AccessibilityExtensionAbility.onKeyEvent
...
@@ -198,5 +164,5 @@ onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean {
...
@@ -198,5 +164,5 @@ onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean {
return
true
;
return
true
;
}
}
return
false
;
return
false
;
}
}
;
```
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录