提交 c4c91b97 编写于 作者: Z zaki

fix sample code problems in accessibility docs

Signed-off-by: Nzaki <zhoujun141@huawei.com>
Change-Id: Idf1970f0033252f02cb403a52551fad072594c20
上级 5c1b453a
......@@ -64,6 +64,7 @@ enableAbility(name: string, capability: Array&lt;accessibility.Capability&gt;):
**示例:**
```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&lt;accessibility.Capability&gt;, 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.
先完成此消息的编辑!
想要评论请 注册