Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
7109e359
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,发现更多精彩内容 >>
提交
7109e359
编写于
2月 28, 2023
作者:
E
ester.zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update doc (14771)
Signed-off-by:
N
ester.zhou
<
ester.zhou@huawei.com
>
上级
32ee7ebd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
55 deletion
+55
-55
en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md
...s-apis-inner-application-accessibilityExtensionContext.md
+55
-55
未找到文件。
en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md
浏览文件 @
7109e359
...
...
@@ -15,7 +15,7 @@ You can use the APIs of this module to configure the concerned information, obta
Before using the
**AccessibilityExtensionContext**
module, you must define a child class that inherits from
**AccessibilityExtensionAbility**
.
```
ts
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
;
let
axContext
;
class
EntryAbility
extends
AccessibilityExtensionAbility
{
onConnect
():
void
{
...
...
@@ -103,10 +103,10 @@ try {
axContext
.
setTargetBundleName
(
targetNames
).
then
(()
=>
{
console
.
info
(
'
set target bundle names success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to set target bundle names, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to set target bundle names, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to set target bundle names, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to set target bundle names, because
${JSON.stringify(exception)}
'
);
};
```
...
...
@@ -132,13 +132,13 @@ let targetNames = ['com.ohos.xyz'];
try
{
axContext
.
setTargetBundleName
(
targetNames
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to set target bundle names, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to set target bundle names, because
${JSON.stringify(err)}
'
);
return
;
}
console
.
info
(
'
set target bundle names success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to set target bundle names, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to set target bundle names, because
${JSON.stringify(exception)}
'
);
};
```
...
...
@@ -179,10 +179,10 @@ try {
focusElement
=
data
;
console
.
log
(
'
get focus element success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get focus element, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to get focus element, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get focus element, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to get focus element, because
${JSON.stringify(exception)}
'
);
}
```
...
...
@@ -215,14 +215,14 @@ let focusElement;
try
{
axContext
.
getFocusElement
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get focus element, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to get focus element, because
${JSON.stringify(err)}
'
);
return
;
}
focusElement
=
data
;
console
.
info
(
'
get focus element success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get focus element, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to get focus element, because
${JSON.stringify(exception)}
'
);
}
```
...
...
@@ -249,14 +249,14 @@ let isAccessibilityFocus = true;
try
{
axContext
.
getFocusElement
(
isAccessibilityFocus
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get focus element, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to get focus element, because
${JSON.stringify(err)}
'
);
return
;
}
focusElement
=
data
;
console
.
info
(
'
get focus element success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get focus element, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to get focus element, because
${JSON.stringify(exception)}
'
);
}
```
## AccessibilityExtensionContext.getWindowRootElement
...
...
@@ -296,10 +296,10 @@ try {
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
)
);
console
.
error
(
'
failed to get root element of the window, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get root element of the window,
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to get root element of the window,
${JSON.stringify(exception)}
'
);
}
```
...
...
@@ -332,14 +332,14 @@ let rootElement;
try
{
axContext
.
getWindowRootElement
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get root element of the window, because
'
+
JSON
.
stringify
(
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
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get root element of the window, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to get root element of the window, because
${JSON.stringify(exception)}
'
);
}
```
...
...
@@ -374,14 +374,14 @@ let windowId = 10;
try
{
axContext
.
getWindowRootElement
(
windowId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get root element of the window, because
'
+
JSON
.
stringify
(
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
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get root element of the window, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to get root element of the window, because
${JSON.stringify(exception)}
'
);
}
```
...
...
@@ -422,10 +422,10 @@ try {
windows
=
data
;
console
.
log
(
'
get windows success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get windows, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to get windows, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get windows, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to get windows, because
${JSON.stringify(exception)}
'
);
}
```
...
...
@@ -458,14 +458,14 @@ let windows;
try
{
axContext
.
getWindows
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get windows, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to get windows, because
${JSON.stringify(err)}
'
);
return
;
}
windows
=
data
;
console
.
info
(
'
get windows success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get windows, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to get windows, because
${JSON.stringify(exception)}
'
);
}
```
...
...
@@ -500,14 +500,14 @@ let displayId = 10;
try
{
axContext
.
getWindows
(
displayId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get windows, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to get windows, because
${JSON.stringify(err)}
'
);
return
;
}
windows
=
data
;
console
.
info
(
'
get windows success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get windows, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to get windows, because
${JSON.stringify(exception)}
'
);
}
```
...
...
@@ -542,7 +542,7 @@ For details about the error codes, see [Accessibility Error Codes](../errorcodes
**Example**
```
ts
import
GesturePath
from
"
@ohos.accessibility.GesturePath
"
;
import
GesturePath
from
'
@ohos.accessibility.GesturePath
'
;
import
GesturePoint
from
'
@ohos.accessibility.GesturePoint
'
;
let
gesturePath
=
new
GesturePath
.
GesturePath
(
100
);
try
{
...
...
@@ -553,10 +553,10 @@ try {
axContext
.
injectGesture
(
gesturePath
).
then
(()
=>
{
console
.
info
(
'
inject gesture success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to inject gesture, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to inject gesture, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to inject gesture, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to inject gesture, because
${JSON.stringify(exception)}
'
);
}
```
## AccessibilityExtensionContext.injectGesture
...
...
@@ -585,7 +585,7 @@ For details about the error codes, see [Accessibility Error Codes](../errorcodes
**Example**
```
ts
import
GesturePath
from
"
@ohos.accessibility.GesturePath
"
;
import
GesturePath
from
'
@ohos.accessibility.GesturePath
'
;
import
GesturePoint
from
'
@ohos.accessibility.GesturePoint
'
;
let
gesturePath
=
new
GesturePath
.
GesturePath
(
100
);
try
{
...
...
@@ -595,13 +595,13 @@ try {
}
axContext
.
injectGesture
(
gesturePath
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to inject gesture, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to inject gesture, because
${JSON.stringify(err)}
'
);
return
;
}
console
.
info
(
'
inject gesture success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to inject gesture, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
'
failed to inject gesture, because
${JSON.stringify(exception)}
'
);
}
```
## AccessibilityElement<sup>9+</sup>
...
...
@@ -633,7 +633,7 @@ rootElement.attributeNames().then((data) => {
console
.
log
(
'
get attribute names success
'
);
attributeNames
=
data
;
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to get attribute names, because
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
'
failed to get attribute names, because
${JSON.stringify(err)}
'
);
});
```
## attributeNames
...
...
@@ -657,7 +657,7 @@ let rootElement;
let
attributeNames
;
rootElement
.
attributeNames
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get attribute names, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to get attribute names, because
${JSON.stringify(err)}
'
);
return
;
}
attributeNames
=
data
;
...
...
@@ -703,10 +703,10 @@ try {
console
.
log
(
'
get attribute value by name success
'
);
attributeValue
=
data
;
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to get attribute value, because
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
'
failed to get attribute value, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to get attribute value, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to get attribute value, because
${JSON.stringify(exception)}
'
);
}
```
## AccessibilityElement.attributeValue
...
...
@@ -742,14 +742,14 @@ let attributeName = 'name';
try
{
rootElement
.
attributeValue
(
attributeName
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get attribute value, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to get attribute value, because
${JSON.stringify(err)}
'
);
return
;
}
attributeValue
=
data
;
console
.
info
(
'
get attribute value success
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to get attribute value, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to get attribute value, because
${JSON.stringify(exception)}
'
);
}
```
## actionNames
...
...
@@ -775,7 +775,7 @@ rootElement.actionNames().then((data) => {
console
.
log
(
'
get action names success
'
);
actionNames
=
data
;
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to get action names because
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
'
failed to get action names because
${JSON.stringify(err)}
'
);
});
```
## actionNames
...
...
@@ -799,7 +799,7 @@ let rootElement;
let
actionNames
;
rootElement
.
actionNames
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get action names, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to get action names, because
${JSON.stringify(err)}
'
);
return
;
}
actionNames
=
data
;
...
...
@@ -843,10 +843,10 @@ try {
rootElement
.
performAction
(
'
action
'
).
then
((
data
)
=>
{
console
.
info
(
'
perform action success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to perform action, because
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
'
failed to perform action, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to perform action, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to perform action, because
${JSON.stringify(exception)}
'
);
}
```
## performAction
...
...
@@ -879,13 +879,13 @@ let rootElement;
try
{
rootElement
.
performAction
(
'
action
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to perform action, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to perform action, because
${JSON.stringify(err)}
'
);
return
;
}
console
.
info
(
'
perform action success
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to perform action, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to perform action, because
${JSON.stringify(exception)}
'
);
}
```
## performAction
...
...
@@ -923,13 +923,13 @@ let parameters = {
try
{
rootElement
.
performAction
(
actionName
,
parameters
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to perform action, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to perform action, because
${JSON.stringify(err)}
'
);
return
;
}
console
.
info
(
'
perform action success
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to perform action, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to perform action, because
${JSON.stringify(exception)}
'
);
}
```
## findElement('content')
...
...
@@ -965,10 +965,10 @@ try {
elements
=
data
;
console
.
log
(
'
find element success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to find element, because
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
'
failed to find element, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to find element, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to find element, because
${JSON.stringify(exception)}
'
);
}
```
## findElement('content')
...
...
@@ -997,14 +997,14 @@ let elements;
try
{
rootElement
.
findElement
(
type
,
condition
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to find element, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to find element, because
${JSON.stringify(err)}
'
);
return
;
}
elements
=
data
;
console
.
info
(
'
find element success
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to find element, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to find element, because
${JSON.stringify(exception)}
'
);
}
```
## findElement('focusType')
...
...
@@ -1040,10 +1040,10 @@ try {
element
=
data
;
console
.
log
(
'
find element success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to find element, because
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
'
failed to find element, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to find element, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to find element, because
${JSON.stringify(exception)}
'
);
}
```
## findElement('focusType')
...
...
@@ -1072,14 +1072,14 @@ let element;
try
{
rootElement
.
findElement
(
type
,
condition
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to find element, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to find element, because
${JSON.stringify(err)}
'
);
return
;
}
element
=
data
;
console
.
info
(
'
find element success
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to find element, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to find element, because
${JSON.stringify(exception)}
'
);
}
```
## findElement('focusDirection')
...
...
@@ -1115,10 +1115,10 @@ try {
element
=
data
;
console
.
log
(
'
find element success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to find element, because
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
'
failed to find element, because
${JSON.stringify(err)}
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to find element, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to find element, because
${JSON.stringify(exception)}
'
);
}
```
## findElement('focusDirection')
...
...
@@ -1147,13 +1147,13 @@ let elements;
try
{
rootElement
.
findElement
(
type
,
condition
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to find element, because
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
'
failed to find element, because
${JSON.stringify(err)}
'
);
return
;
}
elements
=
data
;
console
.
info
(
'
find element success
'
);
});
}
catch
(
exception
)
{
console
.
log
(
'
failed to find element, because
'
+
JSON
.
stringify
(
exception
)
);
console
.
log
(
'
failed to find element, because
${JSON.stringify(exception)}
'
);
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录