未验证 提交 d190b8de 编写于 作者: O openharmony_ci 提交者: Gitee

!11638 修复无障碍子系统文档中的示例代码问题

Merge pull request !11638 from zaki/master
......@@ -64,6 +64,7 @@ enableAbility(name: string, capability: Array<accessibility.Capability>):
**示例:**
```ts
import accessibility from '@ohos.accessibility';
let name = 'com.ohos.example/axExtension';
let capability : accessibility.Capability[] = ['retrieve'];
try {
......@@ -105,6 +106,7 @@ enableAbility(name: string, capability: Array<accessibility.Capability>, c
**示例:**
```ts
import accessibility from '@ohos.accessibility';
let name = 'com.ohos.example/axExtension';
let capability : accessibility.Capability[] = ['retrieve'];
try {
......
......@@ -210,6 +210,7 @@ getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void;
**示例:**
```ts
let focusElement;
try {
axContext.getFocusElement((err, data) => {
if (err) {
......@@ -242,6 +243,7 @@ getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<Accessib
**示例:**
```ts
let focusElement;
try {
axContext.getFocusElement(isAccessibilityFocus, (err, data) => {
if (err) {
......@@ -324,6 +326,7 @@ getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void;
**示例:**
```ts
let rootElement;
try {
axContext.getWindowRootElement((err, data) => {
if (err) {
......@@ -364,6 +367,7 @@ getWindowRootElement(windowId: number, callback: AsyncCallback\<AccessibilityEle
**示例:**
```ts
let rootElement;
try {
axContext.getWindowRootElement(windowId, (err, data) => {
if (err) {
......@@ -536,10 +540,11 @@ injectGesture(gesturePath: GesturePath): Promise\<void>;
```ts
import GesturePath from "@ohos.accessibility.GesturePath";
let gesturePath = new GesturePath(100);
import GesturePoint from '@ohos.accessibility.GesturePoint';
let gesturePath = new GesturePath.GesturePath(100);
try {
for (let i = 0; i < 10; i++) {
let gesturePoint = new GesturePoint(100, i * 200);
let gesturePoint = new GesturePoint.GesturePoint(100, i * 200);
gesturePath.points.push(gesturePoint);
}
axContext.injectGesture(gesturePath).then(() => {
......@@ -578,10 +583,11 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void
```ts
import GesturePath from "@ohos.accessibility.GesturePath";
let gesturePath = new GesturePath(100);
import GesturePoint from '@ohos.accessibility.GesturePoint';
let gesturePath = new GesturePath.GesturePath(100);
try {
for (let i = 0; i < 10; i++) {
let gesturePoint = new GesturePoint(100, i * 200);
let gesturePoint = new GesturePoint.GesturePoint(100, i * 200);
gesturePath.points.push(gesturePoint);
}
axContext.injectGesture(gesturePath, (err, data) => {
......@@ -687,6 +693,8 @@ attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promi
```ts
let attributeName = 'name';
let attributeValue;
let rootElement;
try {
rootElement.attributeValue(attributeName).then((data) => {
console.log('get attribute value by name success');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册