js-apis-pointer.md 28.5 KB
Newer Older
1
# @ohos.multimodalInput.pointer (鼠标指针)
L
liuwei 已提交
2

M
mayunteng_1 已提交
3
鼠标指针管理模块,用于查询和设置鼠标指针相关属性。
L
liuwei 已提交
4 5 6 7 8 9 10 11 12 13 14

> **说明**:
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

## 导入模块

```js
import pointer from '@ohos.multimodalInput.pointer';
```

M
mayunteng_1 已提交
15
## pointer.setPointerVisible<sup>9+</sup>
L
liuwei 已提交
16

L
liuwei 已提交
17
setPointerVisible(visible: boolean, callback: AsyncCallback&lt;void&gt;): void
L
liuwei 已提交
18

M
mayunteng_1 已提交
19
设置鼠标指针显示或者隐藏,使用AsyncCallback异步方式返回结果。
L
liuwei 已提交
20 21 22 23 24

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**参数**

M
mayunteng_1 已提交
25
| 参数名       | 类型                        | 必填   | 说明                                       |
H
HelloCrease 已提交
26
| -------- | ------------------------- | ---- | ---------------------------------------- |
M
mayunteng_1 已提交
27
| visible  | boolean                   | 是    | 鼠标指针是否显示。 |
M
mayunteng_1 已提交
28
| callback | AsyncCallback&lt;void&gt; | 是    | 回调函数。 |
L
liuwei 已提交
29 30 31 32

**示例**

```js
M
mayunteng_1 已提交
33
try {
M
mayunteng_1 已提交
34 35 36 37 38
  pointer.setPointerVisible(true, (error) => {
    if (error) {
      console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
      return;
    }
M
mayunteng_1 已提交
39 40
    console.log(`Set pointer visible success`);
  });
M
mayunteng_1 已提交
41 42
} catch (error) {
  console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
M
mayunteng_1 已提交
43
}
L
liuwei 已提交
44 45
```

M
mayunteng_1 已提交
46
## pointer.setPointerVisible<sup>9+</sup>
L
liuwei 已提交
47

L
liuwei 已提交
48
setPointerVisible(visible: boolean): Promise&lt;void&gt;
L
liuwei 已提交
49

M
mayunteng_1 已提交
50
设置鼠标指针显示或者隐藏,使用Promise异步方式返回结果。
L
liuwei 已提交
51 52 53 54 55

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**参数**

M
mayunteng_1 已提交
56
| 参数名      | 类型      | 必填   | 说明                                       |
H
HelloCrease 已提交
57
| ------- | ------- | ---- | ---------------------------------------- |
M
mayunteng_1 已提交
58
| visible | boolean | 是    | 鼠标指针是否显示。 |
L
liuwei 已提交
59 60 61

**返回值**

H
HelloCrease 已提交
62 63
| 参数                  | 说明                  |
| ------------------- | ------------------- |
M
mayunteng_1 已提交
64
| Promise&lt;void&gt; | Promise对象。 |
L
liuwei 已提交
65 66 67 68

**示例**

```js
M
mayunteng_1 已提交
69
try {
M
mayunteng_1 已提交
70 71
  pointer.setPointerVisible(false).then(() => {
    console.log(`Set pointer visible success`);
M
mayunteng_1 已提交
72
  });
M
mayunteng_1 已提交
73 74
} catch (error) {
  console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
M
mayunteng_1 已提交
75
}
L
liuwei 已提交
76 77
```

M
mayunteng_1 已提交
78
## pointer.isPointerVisible<sup>9+</sup>
L
liuwei 已提交
79

L
liuwei 已提交
80
isPointerVisible(callback: AsyncCallback&lt;boolean&gt;): void
L
liuwei 已提交
81

M
mayunteng_1 已提交
82
获取鼠标指针显示或隐藏状态,使用AsyncCallback异步方式返回结果。
L
liuwei 已提交
83 84 85 86 87

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**参数**

M
mayunteng_1 已提交
88
| 参数名       | 类型                           | 必填   | 说明             |
H
HelloCrease 已提交
89
| -------- | ---------------------------- | ---- | -------------- |
M
mayunteng_1 已提交
90
| callback | AsyncCallback&lt;boolean&gt; | 是    | 回调函数,异步返回鼠标指针显示或隐藏状态。 |
L
liuwei 已提交
91 92 93 94

**示例**

```js
M
mayunteng_1 已提交
95
try {
M
mayunteng_1 已提交
96 97 98 99 100 101
  pointer.isPointerVisible((error, visible) => {
    if (error) {
      console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
      return;
    }
    console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
M
mayunteng_1 已提交
102
  });
M
mayunteng_1 已提交
103 104
} catch (error) {
  console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
M
mayunteng_1 已提交
105
}
L
liuwei 已提交
106 107
```

M
mayunteng_1 已提交
108
## pointer.isPointerVisible<sup>9+</sup>
L
liuwei 已提交
109 110 111

isPointerVisible(): Promise&lt;boolean&gt;

M
mayunteng_1 已提交
112
获取鼠标指针显示或隐藏状态,使用Promise异步方式返回结果。
L
liuwei 已提交
113 114 115 116 117

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**返回值**

H
HelloCrease 已提交
118 119
| 参数                     | 说明                  |
| ---------------------- | ------------------- |
M
mayunteng_1 已提交
120
| Promise&lt;boolean&gt; | Promise对象,异步返回鼠标指针显示或隐藏状态。 |
L
liuwei 已提交
121 122 123 124

**示例**

```js
M
mayunteng_1 已提交
125 126 127 128 129 130 131
try {
  pointer.isPointerVisible().then((visible) => {
    console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
  });
} catch (error) {
  console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
L
liuwei 已提交
132
```
133 134 135

## pointer.setPointerSpeed<sup>9+</sup>

M
mayunteng_1 已提交
136
setPointerSpeed(speed: number, callback: AsyncCallback&lt;void&gt;): void
137

M
mayunteng_1 已提交
138
设置鼠标移动速度,使用AsyncCallback异步方式返回结果。
139 140 141

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

M
mayunteng_1 已提交
142 143
**系统API**: 此接口为系统接口。

144 145
**参数**

M
mayunteng_1 已提交
146
| 参数名       | 类型                        | 必填   | 说明                                    |
H
HelloCrease 已提交
147
| -------- | ------------------------- | ---- | ------------------------------------- |
M
mayunteng_1 已提交
148
| speed    | number                    | 是    | 鼠标移动速度,范围1-11,默认为5。   |
M
mayunteng_1 已提交
149
| callback | AsyncCallback&lt;void&gt; | 是    | 回调函数。 |
150 151 152 153

**示例**

```js
M
mayunteng_1 已提交
154
try {
M
mayunteng_1 已提交
155 156 157 158 159
  pointer.setPointerSpeed(5, (error) => {
    if (error) {
      console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
      return;
    }
M
mayunteng_1 已提交
160 161
    console.log(`Set pointer speed success`);
  });
M
mayunteng_1 已提交
162
} catch (error) {
M
mayunteng_1 已提交
163
  console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
M
mayunteng_1 已提交
164
}
165 166 167 168 169 170
```

## pointer.setPointerSpeed<sup>9+</sup>

setPointerSpeed(speed: number): Promise&lt;void&gt;

M
mayunteng_1 已提交
171
设置鼠标移动速度,使用Promise异步方式返回结果。
172 173 174

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

M
mayunteng_1 已提交
175 176
**系统API**: 此接口为系统接口。

177 178
**参数**

M
mayunteng_1 已提交
179
| 参数名    | 类型     | 必填   | 说明                                  |
H
HelloCrease 已提交
180
| ----- | ------ | ---- | ----------------------------------- |
M
mayunteng_1 已提交
181
| speed | number | 是    | 鼠标移动速度,范围1-11,默认为5。 |
182 183 184

**返回值**

H
HelloCrease 已提交
185 186
| 参数                  | 说明               |
| ------------------- | ---------------- |
M
mayunteng_1 已提交
187
| Promise&lt;void&gt; | Promise对象。 |
188 189 190 191

**示例**

```js
M
mayunteng_1 已提交
192
try {
M
mayunteng_1 已提交
193
  pointer.setPointerSpeed(5).then(() => {
M
mayunteng_1 已提交
194 195
    console.log(`Set pointer speed success`);
  });
M
mayunteng_1 已提交
196 197
} catch (error) {
  console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
M
mayunteng_1 已提交
198
}
199 200 201 202 203 204
```

## pointer.getPointerSpeed<sup>9+</sup>

getPointerSpeed(callback: AsyncCallback&lt;number&gt;): void

M
mayunteng_1 已提交
205
获取鼠标移动速度,使用AsyncCallback异步方式返回结果。
206 207 208

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

M
mayunteng_1 已提交
209 210
**系统API**: 此接口为系统接口。

211 212
**参数**

M
mayunteng_1 已提交
213
| 参数名       | 类型                          | 必填   | 说明             |
H
HelloCrease 已提交
214
| -------- | --------------------------- | ---- | -------------- |
M
mayunteng_1 已提交
215
| callback | AsyncCallback&lt;number&gt; | 是    | 回调函数,异步返回鼠标移动速度。 |
216 217 218 219

**示例**

```js
M
mayunteng_1 已提交
220
try {
M
mayunteng_1 已提交
221
  pointer.getPointerSpeed((error, speed) => {
M
mayunteng_1 已提交
222 223 224 225 226
    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)}`);
M
mayunteng_1 已提交
227
  });
M
mayunteng_1 已提交
228
} catch (error) {
M
mayunteng_1 已提交
229
  console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
M
mayunteng_1 已提交
230
}
231 232 233 234 235 236
```

## pointer.getPointerSpeed<sup>9+</sup>

getPointerSpeed(): Promise&lt;number&gt;

M
mayunteng_1 已提交
237
获取当前鼠标移动速度,使用Promise异步方式返回结果。
238 239 240

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

M
mayunteng_1 已提交
241 242
**系统API**: 此接口为系统接口。

243 244
**返回值**

H
HelloCrease 已提交
245 246
| 参数                    | 说明                  |
| --------------------- | ------------------- |
M
mayunteng_1 已提交
247
| Promise&lt;number&gt; | Promise实例,异步返回鼠标移动速度。 |
248 249 250 251

**示例**

```js
M
mayunteng_1 已提交
252
try {
M
mayunteng_1 已提交
253 254
  pointer.getPointerSpeed().then(speed => {
    console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`);
M
mayunteng_1 已提交
255
  });
M
mayunteng_1 已提交
256 257
} catch (error) {
  console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
M
mayunteng_1 已提交
258
}
259 260
```

X
xixian_2023 已提交
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
## pointer.setHoverScrollState<sup>10+</sup>

setHoverScrollState(state: boolean, callback: AsyncCallback&lt;void&gt;): void

设置鼠标悬停滚动开关状态,使用AsyncCallback异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**参数**

| 参数名       | 类型                        | 必填   | 说明                                    |
| -------- | ------------------------- | ---- | ------------------------------------- |
| state    | boolean                    | 是    | 鼠标悬停滚动开关状态。   |
| callback | AsyncCallback&lt;void&gt; | 是    | 回调函数。 |

**示例**

```js
try {
  pointer.setHoverScrollState(true, (error) => {
    if (error) {
      console.log(`Set the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
      return;
    }
    console.log(`Set the mouse hover scroll success`);
  });
} catch (error) {
  console.log(`Set the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.setHoverScrollState<sup>10+</sup>

setHoverScrollState(state: boolean): Promise&lt;void&gt;

设置鼠标悬停滚动开关状态,使用Promise异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**参数**

| 参数名    | 类型     | 必填   | 说明                                  |
| ----- | ------ | ---- | ----------------------------------- |
| state | boolean | 是    | 鼠标悬停滚动开关状态。 |

**返回值**

| 参数                  | 说明               |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise对象。 |

**示例**

```js
try {
  pointer.setHoverScrollState(true).then(() => {
    console.log(`Set the mouse hover scroll success`);
  });
} catch (error) {
  console.log(`Set the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.getHoverScrollState<sup>10+</sup>

getHoverScrollState(callback: AsyncCallback&lt;boolean&gt;): void

获取鼠标悬停滚动开关状态,使用AsyncCallback异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**参数**

| 参数名       | 类型                          | 必填   | 说明             |
| -------- | --------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;boolean&gt; | 是    | 回调函数,异步返回鼠标悬停滚动开关状态。 |

**示例**

```js
try {
  pointer.getHoverScrollState((error, state) => {
    console.log(`Get the mouse hover scroll success, state: ${JSON.stringify(state)}`);
  });
} catch (error) {
  console.log(`Get the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.getHoverScrollState<sup>10+</sup>

getHoverScrollState(): Promise&lt;boolean&gt;

获取当前鼠标悬停滚动开关状态,使用Promise异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**返回值**

| 参数                    | 说明                  |
| --------------------- | ------------------- |
| Promise&lt;boolean&gt; | Promise实例,异步返回鼠标悬停滚动开关状态。 |

**示例**

```js
try {
  pointer.getHoverScrollState().then((state) => {
    console.log(`Get the mouse hover scroll success, state: ${JSON.stringify(state)}`);
  });
} catch (error) {
  console.log(`Get the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.setMousePrimaryButton<sup>10+</sup>

setMousePrimaryButton(primary: PrimaryButton, callback: AsyncCallback&lt;void&gt;): void

设置鼠标主键,使用AsyncCallback异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**参数**

| 参数名    | 类型                      | 必填  | 说明                                    |
| -------- | ------------------------- | ----  | ------------------------------------- |
398
| primary  | [PrimaryButton](#PrimaryButton9)   | 是    | 鼠标主键id。   |
X
xixian_2023 已提交
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
| callback | AsyncCallback&lt;void&gt; | 是    | 回调函数。 |

**示例**

```js
try {
  pointer.setMousePrimaryButton(pointer.PrimaryButton.RIGHT, (error) => {
    if (error) {
      console.log(`Set mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
      return;
    }
    console.log(`Set mouse primary button success`);
  });
} catch (error) {
  console.log(`Set mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.setMousePrimaryButton<sup>10+</sup>

setMousePrimaryButton(primary: PrimaryButton): Promise&lt;void&gt;

设置鼠标主键,使用Promise异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**参数**

| 参数名    | 类型     | 必填   | 说明                                  |
| ----- | ------ | ---- | ----------------------------------- |
431
| primary | [PrimaryButton](#PrimaryButton9) | 是    | 鼠标主键id。 |
X
xixian_2023 已提交
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464

**返回值**

| 参数                  | 说明               |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise对象。 |

**示例**

```js
try {
  pointer.setMousePrimaryButton(pointer.PrimaryButton.RIGHT).then(() => {
    console.log(`Set mouse primary button success`);
  });
} catch (error) {
  console.log(`Set mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.getMousePrimaryButton<sup>10+</sup>

getMousePrimaryButton(callback: AsyncCallback&lt;PrimaryButton&gt;): void

获取鼠标主键,使用AsyncCallback异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**参数**

| 参数名       | 类型                          | 必填   | 说明             |
| -------- | --------------------------- | ---- | -------------- |
465
| callback | AsyncCallback&lt;[PrimaryButton](#PrimaryButton9)&gt; | 是    | 回调函数,异步返回鼠标主键。 |
X
xixian_2023 已提交
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492

**示例**

```js
try {
  pointer.getMousePrimaryButton((error, primary) => {
    console.log(`Get mouse primary button success, primary: ${JSON.stringify(primary)}`);
  });
} catch (error) {
  console.log(`Get mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.getMousePrimaryButton<sup>10+</sup>

getMousePrimaryButton(): Promise&lt;PrimaryButton&gt;

获取当前鼠标主键,使用Promise异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**返回值**

| 参数                    | 说明                  |
| --------------------- | ------------------- |
493
| Promise&lt;[PrimaryButton](#PrimaryButton9)&gt; | Promise实例,异步返回鼠标主键。 |
X
xixian_2023 已提交
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640

**示例**

```js
try {
  pointer.getMousePrimaryButton().then((primary) => {
    console.log(`Get mouse primary button success, primary: ${JSON.stringify(primary)}`);
  });
} catch (error) {
  console.log(`Get mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## PrimaryButton<sup>10+</sup>

鼠标主键类型。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

| 名称                               | 值    | 说明     |
| -------------------------------- | ---- | ------ |
| LEFT                          | 0    | 鼠标左键     |
| RIGHT                             | 1    | 鼠标右键   |

## pointer.setMouseScrollRows<sup>10+</sup>

setMouseScrollRows(rows: number, callback: AsyncCallback&lt;void&gt;): void

设置鼠标滚动行数,使用AsyncCallback异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**参数**

| 参数名       | 类型                        | 必填   | 说明                                    |
| -------- | ------------------------- | ---- | ------------------------------------- |
| rows     | number                    | 是    | 鼠标滚动行数,范围1-100,默认为3。   |
| callback | AsyncCallback&lt;void&gt; | 是    | 回调函数。 |

**示例**

```js
try {
  pointer.setMouseScrollRows(1, (error) => {
    if (error) {
      console.log(`setMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
      return;
    }
    console.log(`setMouseScrollRows success`);
  });
} catch (error) {
  console.log(`setMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.setMouseScrollRows<sup>10+</sup>

setMouseScrollRows(speed: number): Promise&lt;void&gt;

设置鼠标滚动行数,使用Promise异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**参数**

| 参数名    | 类型     | 必填   | 说明                                  |
| ----- | ------ | ---- | ----------------------------------- |
| rows  | number | 是    | 鼠标滚动行数,范围1-100,默认为3。 |

**返回值**

| 参数                  | 说明               |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise对象。 |

**示例**

```js
try {
  pointer.setMouseScrollRows(20).then(() => {
    console.log(`setMouseScrollRows success`);
  });
} catch (error) {
  console.log(`setMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.getMouseScrollRows<sup>10+</sup>

getMouseScrollRows(callback: AsyncCallback&lt;number&gt;): void

获取鼠标滚动行数,使用AsyncCallback异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**参数**

| 参数名       | 类型                          | 必填   | 说明             |
| -------- | --------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;number&gt; | 是    | 回调函数,异步返回鼠标滚动行数。 |

**示例**

```js
try {
  pointer.getMouseScrollRows((error, rows) => {
    console.log(`getMouseScrollRows success, rows: ${JSON.stringify(rows)}`);
  });
} catch (error) {
  console.log(`getMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

## pointer.getMouseScrollRows<sup>10+</sup>

getMouseScrollRows(): Promise&lt;number&gt;

获取当前鼠标滚动行数,使用Promise异步方式返回结果。

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**系统API**: 此接口为系统接口。

**返回值**

| 参数                    | 说明                  |
| --------------------- | ------------------- |
| Promise&lt;number&gt; | Promise实例,异步返回鼠标滚动行数。 |

**示例**

```js
try {
  pointer.getMouseScrollRows().then((rows) => {
    console.log(`getMouseScrollRows success, rows: ${JSON.stringify(rows)}`);
  });
} catch (error) {
  console.log(`getMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```

641 642
## pointer.getPointerStyle<sup>9+</sup>

643
getPointerStyle(windowId: number, callback: AsyncCallback&lt;PointerStyle&gt;): void
644

M
mayunteng_1 已提交
645
获取鼠标样式类型,使用AsyncCallback异步方式返回结果。
646 647 648 649 650

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**参数**

M
mayunteng_1 已提交
651
| 参数名       | 类型                                       | 必填   | 说明             |
H
HelloCrease 已提交
652
| -------- | ---------------------------------------- | ---- | -------------- |
M
mayunteng_1 已提交
653 654
| windowId | number                                   | 是    | 窗口id。    |
| callback | AsyncCallback&lt;[PointerStyle](#pointerstyle9)&gt; | 是    | 回调函数,异步返回鼠标样式类型。 |
655 656 657 658

**示例**

```js
659
import window from '@ohos.window';
M
mayunteng_1 已提交
660

661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
window.getLastWindow(this.context, (error, win) => {
  if (error.code) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
    return;
  }
  let windowId = win.getWindowProperties().id;
  if (windowId < 0) {
    console.log(`Invalid windowId`);
    return;
  }
  try {
    pointer.getPointerStyle(windowId, (error, style) => {
      console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
    });
  } catch (error) {
    console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
678 679 680 681 682
});
```

## pointer.getPointerStyle<sup>9+</sup>

683
getPointerStyle(windowId: number): Promise&lt;PointerStyle&gt;
684

M
mayunteng_1 已提交
685
获取鼠标样式类型,使用Promise异步方式返回结果。
686 687 688 689 690

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**参数**

M
mayunteng_1 已提交
691
| 参数名     | 类型   | 必填 | 说明     |
M
mayunteng_1 已提交
692 693 694 695 696
| -------- | ------ | ---- | -------- |
| windowId | number | 是   | 窗口id。 |

**返回值**

H
HelloCrease 已提交
697 698
| 参数                                       | 说明                  |
| ---------------------------------------- | ------------------- |
M
mayunteng_1 已提交
699
| Promise&lt;[PointerStyle](#pointerstyle9)&gt; | Promise实例,异步返回鼠标样式类型。 |
700 701 702 703

**示例**

```js
704
import window from '@ohos.window';
M
mayunteng_1 已提交
705

706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722
window.getLastWindow(this.context, (error, win) => {
  if (error.code) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
    return;
  }
  let windowId = win.getWindowProperties().id;
  if (windowId < 0) {
    console.log(`Invalid windowId`);
    return;
  }
  try {
    pointer.getPointerStyle(windowId).then((style) => {
      console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
    });
  } catch (error) {
    console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
723 724 725 726 727
});
```

## pointer.setPointerStyle<sup>9+</sup>

728
setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback&lt;void&gt;): void
729

M
mayunteng_1 已提交
730
设置鼠标样式类型,使用AsyncCallback异步方式返回结果。
731 732 733 734 735

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**参数**

M
mayunteng_1 已提交
736
| 参数名           | 类型                             | 必填   | 说明                                  |
H
HelloCrease 已提交
737
| ------------ | ------------------------------ | ---- | ----------------------------------- |
M
mayunteng_1 已提交
738
| windowId     | number                         | 是    | 窗口id。                          |
H
HelloCrease 已提交
739
| pointerStyle | [PointerStyle](#pointerstyle9) | 是    | 鼠标样式id。                             |
M
mayunteng_1 已提交
740
| callback     | AsyncCallback&lt;void&gt;      | 是    | 回调函数。 |
741 742 743 744

**示例**

```js
745
import window from '@ohos.window';
M
mayunteng_1 已提交
746

747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
window.getLastWindow(this.context, (error, win) => {
  if (error.code) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
    return;
  }
  let windowId = win.getWindowProperties().id;
  if (windowId < 0) {
    console.log(`Invalid windowId`);
    return;
  }
  try {
    pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => {
      console.log(`Set pointer style success`);
    });
  } catch (error) {
    console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
764 765 766 767
});
```
## pointer.setPointerStyle<sup>9+</sup>

768
setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise&lt;void&gt;
769

M
mayunteng_1 已提交
770
设置鼠标样式类型,使用Promise异步方式返回结果。
771 772 773 774 775

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

**参数**

M
mayunteng_1 已提交
776
| 参数名                  | 类型                             | 必填   | 说明               |
H
HelloCrease 已提交
777
| ------------------- | ------------------------------ | ---- | ---------------- |
M
mayunteng_1 已提交
778
| windowId            | number                         | 是    | 窗口id。       |
H
HelloCrease 已提交
779
| pointerStyle        | [PointerStyle](#pointerstyle9) | 是    | 鼠标样式id。          |
M
mayunteng_1 已提交
780
| Promise&lt;void&gt; | void                           | 是    | Promise对象。 |
781 782 783 784

**示例**

```js
785
import window from '@ohos.window';
M
mayunteng_1 已提交
786

787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803
window.getLastWindow(this.context, (error, win) => {
  if (error.code) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
    return;
  }
  let windowId = win.getWindowProperties().id;
  if (windowId < 0) {
    console.log(`Invalid windowId`);
    return;
  }
  try {
    pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => {
      console.log(`Set pointer style success`);
    });
  } catch (error) {
    console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
804 805 806 807
});
```
## PointerStyle<sup>9+</sup>

M
mayunteng_1 已提交
808
鼠标样式类型。
809 810 811

**系统能力**:SystemCapability.MultimodalInput.Input.Pointer

812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
| 名称                               | 值    | 说明     |图示 |
| -------------------------------- | ---- | ------ |------ |
| DEFAULT                          | 0    | 默认     |![Default.png](./figures/Default.png)|
| EAST                             | 1    | 向东箭头   |![East.png](./figures/East.png)|
| WEST                             | 2    | 向西箭头   |![West.png](./figures/West.png)|
| SOUTH                            | 3    | 向南箭头   |![South.png](./figures/South.png)|
| NORTH                            | 4    | 向北箭头   |![North.png](./figures/North.png)|
| WEST_EAST                        | 5    | 向西东箭头  |![West_East.png](./figures/West_East.png)|
| NORTH_SOUTH                      | 6    | 向北南箭头  |![North_South.png](./figures/North_South.png)|
| NORTH_EAST                       | 7    | 向东北箭头  |![North_East.png](./figures/North_East.png)|
| NORTH_WEST                       | 8    | 向西北箭头  |![North_West.png](./figures/North_West.png)|
| SOUTH_EAST                       | 9    | 向东南箭头  |![South_East.png](./figures/South_East.png)|
| SOUTH_WEST                       | 10   | 向西南箭头  |![South_West.png](./figures/South_West.png)|
| NORTH_EAST_SOUTH_WEST            | 11   | 东北西南调整 |![North_East_South_West.png](./figures/North_East_South_West.png)|
| NORTH_WEST_SOUTH_EAST            | 12   | 西北东南调整 |![North_West_South_East.png](./figures/North_West_South_East.png)|
| CROSS                            | 13   | 准确选择   |![Cross.png](./figures/Cross.png)|
| CURSOR_COPY                      | 14   | 拷贝     |![Copy.png](./figures/Copy.png)|
| CURSOR_FORBID                    | 15   | 不可用    |![Forbid.png](./figures/Forbid.png)|
| COLOR_SUCKER                     | 16   | 滴管     |![Colorsucker.png](./figures/Colorsucker.png)|
| HAND_GRABBING                    | 17   | 并拢的手   |![Hand_Grabbing.png](./figures/Hand_Grabbing.png)|
| HAND_OPEN                        | 18   | 张开的手   |![Hand_Open.png](./figures/Hand_Open.png)|
| HAND_POINTING                    | 19   | 手形指针   |![Hand_Poniting.png](./figures/Hand_Pointing.png)|
| HELP                             | 20   | 帮助选择   |![Help.png](./figures/Help.png)|
| MOVE                             | 21   | 移动     |![Move.png](./figures/Move.png)|
| RESIZE_LEFT_RIGHT                | 22   | 内部左右调整 |![Resize_Left_Right.png](./figures/Resize_Left_Right.png)|
| RESIZE_UP_DOWN                   | 23   | 内部上下调整 |![Resize_Up_Down.png](./figures/Resize_Up_Down.png)|
| SCREENSHOT_CHOOSE                | 24   | 截图十字准星 |![Screenshot_Cross.png](./figures/Screenshot_Cross.png)|
| SCREENSHOT_CURSOR                | 25   | 截图     |![Screenshot_Cursor.png](./figures/Screenshot_Cursor.png)|
| TEXT_CURSOR                      | 26   | 文本选择   |![Text_Cursor.png](./figures/Text_Cursor.png)|
| ZOOM_IN                          | 27   | 放大     |![Zoom_In.png](./figures/Zoom_In.png)|
| ZOOM_OUT                         | 28   | 缩小     |![Zoom_Out.png](./figures/Zoom_Out.png)|
| MIDDLE_BTN_EAST                  | 29   | 向东滚动   |![MID_Btn_East.png](./figures/MID_Btn_East.png)|
| MIDDLE_BTN_WEST                  | 30   | 向西滚动   |![MID_Btn_West.png](./figures/MID_Btn_West.png)|
| MIDDLE_BTN_SOUTH                 | 31   | 向南滚动   | ![MID_Btn_South.png](./figures/MID_Btn_South.png)            |
| MIDDLE_BTN_NORTH                 | 32   | 向北滚动   |![MID_Btn_North.png](./figures/MID_Btn_North.png)|
| MIDDLE_BTN_NORTH_SOUTH           | 33   | 向北南滚动  |![MID_Btn_North_South.png](./figures/MID_Btn_North_South.png)|
| MIDDLE_BTN_NORTH_EAST            | 34   | 向东北滚动  |![MID_Btn_North_East.png](./figures/MID_Btn_North_East.png)|
| MIDDLE_BTN_NORTH_WEST            | 35   | 向西北滚动  |![MID_Btn_North_West.png](./figures/MID_Btn_North_West.png)|
| MIDDLE_BTN_SOUTH_EAST            | 36   | 向东南滚动  |![MID_Btn_South_East.png](./figures/MID_Btn_South_East.png)|
| MIDDLE_BTN_SOUTH_WEST            | 37   | 向西南滚动  |![MID_Btn_South_West.png](./figures/MID_Btn_South_West.png)|
| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38   | 四向锥形移动 |![MID_Btn_North_South_West_East.png](./figures/MID_Btn_North_South_West_East.png)|