1# @ohos.multimodalInput.pointer (Mouse Pointer) 2 3The **pointer** module provides APIs related to pointer attribute management. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```js 12import pointer from '@ohos.multimodalInput.pointer'; 13``` 14 15## pointer.setPointerVisible 16 17setPointerVisible(visible: boolean, callback: AsyncCallback<void>): void 18 19Sets the visible status of the mouse pointer. This API uses an asynchronous callback to return the result. 20 21**System capability**: SystemCapability.MultimodalInput.Input.Pointer 22 23**Parameters** 24 25| Name | Type | Mandatory | Description | 26| -------- | ------------------------- | ---- | ---------------------------------------- | 27| visible | boolean | Yes | Whether the mouse pointer is visible. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.| 28| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 29 30**Example** 31 32```js 33try { 34 pointer.setPointerVisible(true, (error: Error) => { 35 if (error) { 36 console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 37 return; 38 } 39 console.log(`Set pointer visible success`); 40 }); 41} catch (error) { 42 console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 43} 44``` 45 46## pointer.setPointerVisible 47 48setPointerVisible(visible: boolean): Promise<void> 49 50Sets the visible status of the mouse pointer. This API uses a promise to return the result. 51 52**System capability**: SystemCapability.MultimodalInput.Input.Pointer 53 54**Parameters** 55 56| Name | Type | Mandatory | Description | 57| ------- | ------- | ---- | ---------------------------------------- | 58| visible | boolean | Yes | Whether the mouse pointer is visible. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.| 59 60**Return value** 61 62| Name | Description | 63| ------------------- | ------------------- | 64| Promise<void> | Promise used to return the result.| 65 66**Example** 67 68```js 69try { 70 pointer.setPointerVisible(false).then(() => { 71 console.log(`Set pointer visible success`); 72 }); 73} catch (error) { 74 console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 75} 76``` 77 78## pointer.setPointerVisibleSync<sup>10+</sup> 79 80setPointerVisibleSync(visible: boolean): void 81 82Sets the visible status of the mouse pointer. This API returns the result synchronously. 83 84**System capability**: SystemCapability.MultimodalInput.Input.Pointer 85 86**Parameters** 87 88| Name | Type | Mandatory | Description | 89| ------- | ------- | ---- | ---------------------------------------- | 90| visible | boolean | Yes | Whether the mouse pointer is visible. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.| 91 92**Example** 93 94```js 95try { 96 pointer.setPointerVisibleSync(false); 97 console.log(`Set pointer visible success`); 98} catch (error) { 99 console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 100} 101``` 102 103## pointer.isPointerVisible 104 105isPointerVisible(callback: AsyncCallback<boolean>): void 106 107Checks the visible status of the mouse pointer. This API uses an asynchronous callback to return the result. 108 109**System capability**: SystemCapability.MultimodalInput.Input.Pointer 110 111**Parameters** 112 113| Name | Type | Mandatory | Description | 114| -------- | ---------------------------- | ---- | -------------- | 115| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| 116 117**Example** 118 119```js 120try { 121 pointer.isPointerVisible((error: Error, visible: boolean) => { 122 if (error) { 123 console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 124 return; 125 } 126 console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`); 127 }); 128} catch (error) { 129 console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 130} 131``` 132 133## pointer.isPointerVisible 134 135isPointerVisible(): Promise<boolean> 136 137Checks the visible status of the mouse pointer. This API uses a promise to return the result. 138 139**System capability**: SystemCapability.MultimodalInput.Input.Pointer 140 141**Return value** 142 143| Name | Description | 144| ---------------------- | ------------------- | 145| Promise<boolean> | Promise used to return the result.| 146 147**Example** 148 149```js 150try { 151 pointer.isPointerVisible().then((visible: boolean) => { 152 console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`); 153 }); 154} catch (error) { 155 console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 156} 157``` 158 159## pointer.isPointerVisibleSync<sup>10+</sup> 160 161isPointerVisibleSync(): boolean 162 163Obtains the visible status of the mouse pointer. This API returns the result synchronously. 164 165**System capability**: SystemCapability.MultimodalInput.Input.Pointer 166 167**Return value** 168 169| Name | Description | 170| ---------------------- | ------------------- | 171| boolean | Visible status of the mouse pointer. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.| 172 173**Example** 174 175```js 176try { 177 let visible: boolean = pointer.isPointerVisibleSync(); 178 console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`); 179} catch (error) { 180 console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 181} 182``` 183 184## pointer.setPointerSpeed 185 186setPointerSpeed(speed: number, callback: AsyncCallback<void>): void 187 188Sets the moving speed of the mouse pointer. This API uses an asynchronous callback to return the result. 189 190**System capability**: SystemCapability.MultimodalInput.Input.Pointer 191 192**System API**: This is a system API. 193 194**Parameters** 195 196| Name | Type | Mandatory | Description | 197| -------- | ------------------------- | ---- | ------------------------------------- | 198| speed | number | Yes | Moving speed of the mouse pointer. The value ranges from **1** to **11**. The default value is **5**. | 199| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 200 201**Example** 202 203```js 204try { 205 pointer.setPointerSpeed(5, (error: Error) => { 206 if (error) { 207 console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 208 return; 209 } 210 console.log(`Set pointer speed success`); 211 }); 212} catch (error) { 213 console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 214} 215``` 216 217## pointer.setPointerSpeed 218 219setPointerSpeed(speed: number): Promise<void> 220 221Sets the moving speed of the mouse pointer. This API uses a promise to return the result. 222 223**System capability**: SystemCapability.MultimodalInput.Input.Pointer 224 225**System API**: This is a system API. 226 227**Parameters** 228 229| Name | Type | Mandatory | Description | 230| ----- | ------ | ---- | ----------------------------------- | 231| speed | number | Yes | Moving speed of the mouse pointer. The value ranges from **1** to **11**. The default value is **5**.| 232 233**Return value** 234 235| Name | Description | 236| ------------------- | ---------------- | 237| Promise<void> | Promise used to return the result.| 238 239**Example** 240 241```js 242try { 243 pointer.setPointerSpeed(5).then(() => { 244 console.log(`Set pointer speed success`); 245 }); 246} catch (error) { 247 console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 248} 249``` 250 251## pointer.setPointerSpeedSync<sup>10+</sup> 252 253setPointerSpeedSync(speed: number): void 254 255Sets the moving speed of the mouse pointer. This API returns the result synchronously. 256 257**System capability**: SystemCapability.MultimodalInput.Input.Pointer 258 259**System API**: This is a system API. 260 261**Parameters** 262 263| Name | Type | Mandatory | Description | 264| ----- | ------ | ---- | ----------------------------------- | 265| speed | number | Yes | Moving speed of the mouse pointer. The value ranges from **1** to **11**. The default value is **5**.| 266 267**Example** 268 269```js 270try { 271 let speed = pointer.setPointerSpeedSync(5); 272 console.log(`Set pointer speed success`); 273} catch (error) { 274 console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 275} 276``` 277 278## pointer.getPointerSpeed 279 280getPointerSpeed(callback: AsyncCallback<number>): void 281 282Obtains the moving speed of the mouse pointer. This API uses an asynchronous callback to return the result. 283 284**System capability**: SystemCapability.MultimodalInput.Input.Pointer 285 286**System API**: This is a system API. 287 288**Parameters** 289 290| Name | Type | Mandatory | Description | 291| -------- | --------------------------- | ---- | -------------- | 292| callback | AsyncCallback<number> | Yes | Callback used to return the result.| 293 294**Example** 295 296```js 297try { 298 pointer.getPointerSpeed((error: Error, speed: number) => { 299 if (error) { 300 console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 301 return; 302 } 303 console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`); 304 }); 305} catch (error) { 306 console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 307} 308``` 309 310## pointer.getPointerSpeed 311 312getPointerSpeed(): Promise<number> 313 314Obtains the moving speed of the mouse pointer. This API uses a promise to return the result. 315 316**System capability**: SystemCapability.MultimodalInput.Input.Pointer 317 318**System API**: This is a system API. 319 320**Return value** 321 322| Name | Description | 323| --------------------- | ------------------- | 324| Promise<number> | Promise used to return the result.| 325 326**Example** 327 328```js 329try { 330 pointer.getPointerSpeed().then(speed => { 331 console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`); 332 }); 333} catch (error) { 334 console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 335} 336``` 337 338## pointer.getPointerSpeedSync<sup>10+</sup> 339 340getPointerSpeedSync(): number 341 342Obtains the moving speed of the mouse pointer. This API returns the result synchronously. 343 344**System capability**: SystemCapability.MultimodalInput.Input.Pointer 345 346**System API**: This is a system API. 347 348**Return value** 349 350| Name | Description | 351| --------------------- | ------------------- | 352| number | Moving speed of the mouse pointer.| 353 354**Example** 355 356```js 357try { 358 let speed = pointer.getPointerSpeedSync(); 359 console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`); 360} catch (error) { 361 console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 362} 363``` 364 365## pointer.setHoverScrollState<sup>10+</sup> 366 367setHoverScrollState(state: boolean, callback: AsyncCallback<void>): void 368 369Sets the status of the mouse hover scroll switch. This API uses an asynchronous callback to return the result. 370 371**System capability**: SystemCapability.MultimodalInput.Input.Pointer 372 373**System API**: This is a system API. 374 375**Parameters** 376 377| Name | Type | Mandatory | Description | 378| -------- | ------------------------- | ---- | ------------------------------------- | 379| state | boolean | Yes | Status of the mouse hover scroll switch. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. | 380| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 381 382**Example** 383 384```js 385try { 386 pointer.setHoverScrollState(true, (error: Error) => { 387 if (error) { 388 console.log(`Set the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 389 return; 390 } 391 console.log(`Set the mouse hover scroll success`); 392 }); 393} catch (error) { 394 console.log(`Set the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 395} 396``` 397 398## pointer.setHoverScrollState<sup>10+</sup> 399 400setHoverScrollState(state: boolean): Promise<void> 401 402Sets the status of the mouse hover scroll switch. This API uses a promise to return the result. 403 404**System capability**: SystemCapability.MultimodalInput.Input.Pointer 405 406**System API**: This is a system API. 407 408**Parameters** 409 410| Name | Type | Mandatory | Description | 411| ----- | ------ | ---- | ----------------------------------- | 412| state | boolean | Yes | Status of the mouse hover scroll switch. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite.| 413 414**Return value** 415 416| Name | Description | 417| ------------------- | ---------------- | 418| Promise<void> | Promise used to return the result.| 419 420**Example** 421 422```js 423try { 424 pointer.setHoverScrollState(true).then(() => { 425 console.log(`Set the mouse hover scroll success`); 426 }); 427} catch (error) { 428 console.log(`Set the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 429} 430``` 431 432## pointer.getHoverScrollState<sup>10+</sup> 433 434getHoverScrollState(callback: AsyncCallback<boolean>): void 435 436Obtains the status of the mouse hover scroll switch. This API uses an asynchronous callback to return the result. 437 438**System capability**: SystemCapability.MultimodalInput.Input.Pointer 439 440**System API**: This is a system API. 441 442**Parameters** 443 444| Name | Type | Mandatory | Description | 445| -------- | --------------------------- | ---- | -------------- | 446| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite.| 447 448**Example** 449 450```js 451try { 452 pointer.getHoverScrollState((error: Error, state: boolean) => { 453 console.log(`Get the mouse hover scroll success, state: ${JSON.stringify(state)}`); 454 }); 455} catch (error) { 456 console.log(`Get the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 457} 458``` 459 460## pointer.getHoverScrollState<sup>10+</sup> 461 462getHoverScrollState(): Promise<boolean> 463 464Obtains the status of the mouse hover scroll switch. This API uses a promise to return the result. 465 466**System capability**: SystemCapability.MultimodalInput.Input.Pointer 467 468**System API**: This is a system API. 469 470**Return value** 471 472| Name | Description | 473| --------------------- | ------------------- | 474| Promise<boolean> | Promise used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite.| 475 476**Example** 477 478```js 479try { 480 pointer.getHoverScrollState().then((state: boolean) => { 481 console.log(`Get the mouse hover scroll success, state: ${JSON.stringify(state)}`); 482 }); 483} catch (error) { 484 console.log(`Get the mouse hover scroll failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 485} 486``` 487 488## pointer.setMousePrimaryButton<sup>10+</sup> 489 490setMousePrimaryButton(primary: PrimaryButton, callback: AsyncCallback<void>): void 491 492Sets the primary button of the mouse. This API uses an asynchronous callback to return the result. 493 494**System capability**: SystemCapability.MultimodalInput.Input.Pointer 495 496**System API**: This is a system API. 497 498**Parameters** 499 500| Name | Type | Mandatory | Description | 501| -------- | ------------------------- | ---- | ------------------------------------- | 502| primary | [PrimaryButton](#primarybutton10) | Yes | ID of the primary mouse button. | 503| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 504 505**Example** 506 507```js 508try { 509 pointer.setMousePrimaryButton(pointer.PrimaryButton.RIGHT, (error: Error) => { 510 if (error) { 511 console.log(`Set mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 512 return; 513 } 514 console.log(`Set mouse primary button success`); 515 }); 516} catch (error) { 517 console.log(`Set mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 518} 519``` 520 521## pointer.setMousePrimaryButton<sup>10+</sup> 522 523setMousePrimaryButton(primary: PrimaryButton): Promise<void> 524 525Sets the primary button of the mouse. This API uses a promise to return the result. 526 527**System capability**: SystemCapability.MultimodalInput.Input.Pointer 528 529**System API**: This is a system API. 530 531**Parameters** 532 533| Name | Type | Mandatory | Description | 534| ----- | ------ | ---- | ----------------------------------- | 535| primary | [PrimaryButton](#primarybutton10) | Yes | ID of the primary mouse button.| 536 537**Return value** 538 539| Name | Description | 540| ------------------- | ---------------- | 541| Promise<void> | Promise used to return the result.| 542 543**Example** 544 545```js 546try { 547 pointer.setMousePrimaryButton(pointer.PrimaryButton.RIGHT).then(() => { 548 console.log(`Set mouse primary button success`); 549 }); 550} catch (error) { 551 console.log(`Set mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 552} 553``` 554 555## pointer.getMousePrimaryButton<sup>10+</sup> 556 557getMousePrimaryButton(callback: AsyncCallback<PrimaryButton>): void 558 559Obtains the primary button of the mouse. This API uses an asynchronous callback to return the result. 560 561**System capability**: SystemCapability.MultimodalInput.Input.Pointer 562 563**System API**: This is a system API. 564 565**Parameters** 566 567| Name | Type | Mandatory | Description | 568| -------- | --------------------------- | ---- | -------------- | 569| callback | AsyncCallback<[PrimaryButton](#primarybutton10)> | Yes | Callback used to return the result.| 570 571**Example** 572 573```js 574try { 575 pointer.getMousePrimaryButton((error: Error, primary: pointer.PrimaryButton) => { 576 console.log(`Get mouse primary button success, primary: ${JSON.stringify(primary)}`); 577 }); 578} catch (error) { 579 console.log(`Get mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 580} 581``` 582 583## pointer.getMousePrimaryButton<sup>10+</sup> 584 585getMousePrimaryButton(): Promise<PrimaryButton> 586 587Obtains the primary button of the mouse. This API uses a promise to return the result. 588 589**System capability**: SystemCapability.MultimodalInput.Input.Pointer 590 591**System API**: This is a system API. 592 593**Return value** 594 595| Name | Description | 596| --------------------- | ------------------- | 597| Promise<[PrimaryButton](#primarybutton10)> | Promise used to return the result.| 598 599**Example** 600 601```js 602try { 603 pointer.getMousePrimaryButton().then((primary: pointer.PrimaryButton) => { 604 console.log(`Get mouse primary button success, primary: ${JSON.stringify(primary)}`); 605 }); 606} catch (error) { 607 console.log(`Get mouse primary button failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 608} 609``` 610 611## PrimaryButton<sup>10+</sup> 612 613Type of the primary mouse button. 614 615**System capability**: SystemCapability.MultimodalInput.Input.Pointer 616 617| Name | Value | Description | 618| -------------------------------- | ---- | ------ | 619| LEFT | 0 | Left mouse button. | 620| RIGHT | 1 | Right mouse button. | 621 622## pointer.setMouseScrollRows<sup>10+</sup> 623 624setMouseScrollRows(rows: number, callback: AsyncCallback<void>): void 625 626Sets the number of mouse scroll rows. This API uses an asynchronous callback to return the result. 627 628**System capability**: SystemCapability.MultimodalInput.Input.Pointer 629 630**System API**: This is a system API. 631 632**Parameters** 633 634| Name | Type | Mandatory | Description | 635| -------- | ------------------------- | ---- | ------------------------------------- | 636| rows | number | Yes | Number of mouse scroll rows. The value ranges from 1 to 100. The default value is **3**. | 637| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 638 639**Example** 640 641```js 642try { 643 pointer.setMouseScrollRows(1, (error: Error) => { 644 if (error) { 645 console.log(`setMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 646 return; 647 } 648 console.log(`setMouseScrollRows success`); 649 }); 650} catch (error) { 651 console.log(`setMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 652} 653``` 654 655## pointer.setMouseScrollRows<sup>10+</sup> 656 657setMouseScrollRows(rows: number): Promise<void> 658 659Sets the number of mouse scroll rows. This API uses a promise to return the result. 660 661**System capability**: SystemCapability.MultimodalInput.Input.Pointer 662 663**System API**: This is a system API. 664 665**Parameters** 666 667| Name | Type | Mandatory | Description | 668| ----- | ------ | ---- | ----------------------------------- | 669| rows | number | Yes | Number of mouse scroll rows. The value ranges from 1 to 100. The default value is **3**.| 670 671**Return value** 672 673| Name | Description | 674| ------------------- | ---------------- | 675| Promise<void> | Promise used to return the result.| 676 677**Example** 678 679```js 680try { 681 pointer.setMouseScrollRows(20).then(() => { 682 console.log(`setMouseScrollRows success`); 683 }); 684} catch (error) { 685 console.log(`setMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 686} 687``` 688 689## pointer.getMouseScrollRows<sup>10+</sup> 690 691getMouseScrollRows(callback: AsyncCallback<number>): void 692 693Obtains the number of mouse scroll rows. This API uses an asynchronous callback to return the result. 694 695**System capability**: SystemCapability.MultimodalInput.Input.Pointer 696 697**System API**: This is a system API. 698 699**Parameters** 700 701| Name | Type | Mandatory | Description | 702| -------- | --------------------------- | ---- | -------------- | 703| callback | AsyncCallback<number> | Yes | Callback used to return the result.| 704 705**Example** 706 707```js 708try { 709 pointer.getMouseScrollRows((error: Error, rows: number) => { 710 console.log(`getMouseScrollRows success, rows: ${JSON.stringify(rows)}`); 711 }); 712} catch (error) { 713 console.log(`getMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 714} 715``` 716 717## pointer.getMouseScrollRows<sup>10+</sup> 718 719getMouseScrollRows(): Promise<number> 720 721Obtains the moving speed of the mouse pointer. This API uses a promise to return the result. 722 723**System capability**: SystemCapability.MultimodalInput.Input.Pointer 724 725**System API**: This is a system API. 726 727**Return value** 728 729| Name | Description | 730| --------------------- | ------------------- | 731| Promise<number> | Promise used to return the result.| 732 733**Example** 734 735```js 736try { 737 pointer.getMouseScrollRows().then((rows: number) => { 738 console.log(`getMouseScrollRows success, rows: ${JSON.stringify(rows)}`); 739 }); 740} catch (error) { 741 console.log(`getMouseScrollRows failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 742} 743``` 744 745## pointer.getPointerStyle 746 747getPointerStyle(windowId: number, callback: AsyncCallback<PointerStyle>): void 748 749Obtains the mouse pointer style. This API uses an asynchronous callback to return the result. 750 751**System capability**: SystemCapability.MultimodalInput.Input.Pointer 752 753**Parameters** 754 755| Name | Type | Mandatory | Description | 756| -------- | ---------------------------------------- | ---- | -------------- | 757| windowId | number | Yes | Window ID. | 758| callback | AsyncCallback<[PointerStyle](#pointerstyle)> | Yes | Callback used to return the result.| 759 760**Example** 761 762```js 763import { BusinessError } from '@ohos.base'; 764import window from '@ohos.window'; 765 766let context = getContext(this); 767window.getLastWindow(context, (error: BusinessError, win: window.Window) => { 768 if (error.code) { 769 console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); 770 return; 771 } 772 let windowId = win.getWindowProperties().id; 773 if (windowId < 0) { 774 console.log(`Invalid windowId`); 775 return; 776 } 777 try { 778 pointer.getPointerStyle(windowId, (error: Error, style: pointer.PointerStyle) => { 779 console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); 780 }); 781 } catch (error) { 782 console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 783 } 784}); 785``` 786 787## pointer.getPointerStyle 788 789getPointerStyle(windowId: number): Promise<PointerStyle> 790 791Obtains the mouse pointer style. This API uses a promise to return the result. 792 793**System capability**: SystemCapability.MultimodalInput.Input.Pointer 794 795**Parameters** 796 797| Name | Type | Mandatory| Description | 798| -------- | ------ | ---- | -------- | 799| windowId | number | Yes | Window ID.| 800 801**Return value** 802 803| Name | Description | 804| ---------------------------------------- | ------------------- | 805| Promise<[PointerStyle](#pointerstyle)> | Promise used to return the result.| 806 807**Example** 808 809```js 810import window from '@ohos.window'; 811import { BusinessError } from '@ohos.base'; 812 813let context = getContext(this); 814window.getLastWindow(context, (error: BusinessError, win: window.Window) => { 815 if (error.code) { 816 console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); 817 return; 818 } 819 let windowId = win.getWindowProperties().id; 820 if (windowId < 0) { 821 console.log(`Invalid windowId`); 822 return; 823 } 824 try { 825 pointer.getPointerStyle(windowId).then((style: pointer.PointerStyle) => { 826 console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); 827 }); 828 } catch (error) { 829 console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 830 } 831}); 832``` 833 834## pointer.getPointerStyleSync<sup>10+</sup> 835 836getPointerStyleSync(windowId: number): PointerStyle 837 838Obtains the mouse pointer style. This API returns the result synchronously. 839 840**System capability**: SystemCapability.MultimodalInput.Input.Pointer 841 842**Parameters** 843 844| Name | Type | Mandatory| Description | 845| -------- | ------ | ---- | -------- | 846| windowId | number | Yes | Window ID.| 847 848**Return value** 849 850| Name | Description | 851| ---------------------------------------- | ------------------- | 852| [PointerStyle](#pointerstyle) | Mouse pointer style.| 853 854**Example** 855 856```js 857try { 858 let style: pointer.PointerStyle = pointer.getPointerStyleSync(-1); 859 console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); 860} catch (error) { 861 console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 862} 863``` 864 865## pointer.setPointerStyle 866 867setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback<void>): void 868 869Sets the mouse pointer style. This API uses an asynchronous callback to return the result. 870 871**System capability**: SystemCapability.MultimodalInput.Input.Pointer 872 873**Parameters** 874 875| Name | Type | Mandatory | Description | 876| ------------ | ------------------------------ | ---- | ----------------------------------- | 877| windowId | number | Yes | Window ID. | 878| pointerStyle | [PointerStyle](#pointerstyle) | Yes | Pointer style. | 879| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 880 881**Example** 882 883```js 884import window from '@ohos.window'; 885import { BusinessError } from '@ohos.base'; 886 887window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => { 888 if (error.code) { 889 console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); 890 return; 891 } 892 let windowId = win.getWindowProperties().id; 893 if (windowId < 0) { 894 console.log(`Invalid windowId`); 895 return; 896 } 897 try { 898 pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => { 899 console.log(`Set pointer style success`); 900 }); 901 } catch (error) { 902 console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 903 } 904}); 905``` 906## pointer.setPointerStyle 907 908setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise<void> 909 910Sets the mouse pointer style. This API uses a promise to return the result. 911 912**System capability**: SystemCapability.MultimodalInput.Input.Pointer 913 914**Parameters** 915 916| Name | Type | Mandatory | Description | 917| ------------------- | ------------------------------ | ---- | ---------------- | 918| windowId | number | Yes | Window ID. | 919| pointerStyle | [PointerStyle](#pointerstyle) | Yes | Pointer style. | 920| Promise<void> | void | Yes | Promise used to return the result.| 921 922**Example** 923 924```js 925import window from '@ohos.window'; 926import { BusinessError } from '@ohos.base'; 927 928window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => { 929 if (error.code) { 930 console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); 931 return; 932 } 933 let windowId = win.getWindowProperties().id; 934 if (windowId < 0) { 935 console.log(`Invalid windowId`); 936 return; 937 } 938 try { 939 pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => { 940 console.log(`Set pointer style success`); 941 }); 942 } catch (error) { 943 console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 944 } 945}); 946``` 947 948## pointer.setPointerStyleSync<sup>10+</sup> 949 950setPointerStyleSync(windowId: number, pointerStyle: PointerStyle): void 951 952Sets the mouse pointer style. This API returns the result synchronously. 953 954**System capability**: SystemCapability.MultimodalInput.Input.Pointer 955 956**Parameters** 957 958| Name | Type | Mandatory | Description | 959| ------------------- | ------------------------------ | ---- | ---------------- | 960| windowId | number | Yes | Window ID. | 961| pointerStyle | [PointerStyle](#pointerstyle) | Yes | Pointer style. | 962 963**Example** 964```js 965import window from '@ohos.window'; 966import { BusinessError } from '@ohos.base'; 967 968window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => { 969 if (error.code) { 970 console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); 971 return; 972 } 973 let windowId = win.getWindowProperties().id; 974 if (windowId < 0) { 975 console.log(`Invalid windowId`); 976 return; 977 } 978 try { 979 pointer.setPointerStyleSync(windowId, pointer.PointerStyle.CROSS); 980 console.log(`Set pointer style success`); 981 } catch (error) { 982 console.log(`getPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 983 } 984}); 985``` 986 987## PointerStyle 988 989Enumerates mouse pointer styles. 990 991**System capability**: SystemCapability.MultimodalInput.Input.Pointer 992 993| Name | Value | Description |Legend| 994| -------------------------------- | ---- | ------ |------ | 995| DEFAULT | 0 | Default || 996| EAST | 1 | East arrow || 997| WEST | 2 | West arrow || 998| SOUTH | 3 | South arrow || 999| NORTH | 4 | North arrow || 1000| WEST_EAST | 5 | West-east arrow || 1001| NORTH_SOUTH | 6 | North-south arrow || 1002| NORTH_EAST | 7 | North-east arrow || 1003| NORTH_WEST | 8 | North-west arrow || 1004| SOUTH_EAST | 9 | South-east arrow || 1005| SOUTH_WEST | 10 | South-west arrow || 1006| NORTH_EAST_SOUTH_WEST | 11 | North-east and south-west adjustment|| 1007| NORTH_WEST_SOUTH_EAST | 12 | North-west and south-east adjustment|| 1008| CROSS | 13 | Cross (accurate selection) || 1009| CURSOR_COPY | 14 | Copy || 1010| CURSOR_FORBID | 15 | Forbid || 1011| COLOR_SUCKER | 16 | Sucker || 1012| HAND_GRABBING | 17 | Grabbing hand || 1013| HAND_OPEN | 18 | Opening hand || 1014| HAND_POINTING | 19 | Hand-shaped pointer || 1015| HELP | 20 | Help || 1016| MOVE | 21 | Move || 1017| RESIZE_LEFT_RIGHT | 22 | Left and right resizing|| 1018| RESIZE_UP_DOWN | 23 | Up and down resizing|| 1019| SCREENSHOT_CHOOSE | 24 | Screenshot crosshair|| 1020| SCREENSHOT_CURSOR | 25 | Screenshot || 1021| TEXT_CURSOR | 26 | Text selection || 1022| ZOOM_IN | 27 | Zoom in || 1023| ZOOM_OUT | 28 | Zoom out || 1024| MIDDLE_BTN_EAST | 29 | Scrolling east || 1025| MIDDLE_BTN_WEST | 30 | Scrolling west || 1026| MIDDLE_BTN_SOUTH | 31 | Scrolling south |  | 1027| MIDDLE_BTN_NORTH | 32 | Scrolling north || 1028| MIDDLE_BTN_NORTH_SOUTH | 33 | Scrolling north-south || 1029| MIDDLE_BTN_NORTH_EAST | 34 | Scrolling north-east || 1030| MIDDLE_BTN_NORTH_WEST | 35 | Scrolling north-west || 1031| MIDDLE_BTN_SOUTH_EAST | 36 | Scrolling south-east || 1032| MIDDLE_BTN_SOUTH_WEST | 37 | Scrolling south-west || 1033| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | Moving as a cone in four directions|| 1034| HORIZONTAL_TEXT_CURSOR<sup>10+</sup> | 39 | Horizontal text selection|| 1035| CURSOR_CROSS<sup>10+</sup> | 40 | Cross|| 1036| CURSOR_CIRCLE<sup>10+</sup> | 41 | Circle|| 1037| LOADING<sup>10+</sup> | 42 | Animation loading|| 1038| RUNNING<sup>10+</sup> | 43 | Animation running in the background|| 1039 1040## pointer.setTouchpadScrollSwitch<sup>10+</sup> 1041 1042setTouchpadScrollSwitch(state: boolean, callback: AsyncCallback\<void>): void 1043 1044Sets the scroll switch of the touchpad. This API uses an asynchronous callback to return the result. 1045 1046**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1047 1048**System API**: This is a system API. 1049 1050**Parameters** 1051 1052| Name | Type | Mandatory | Description | 1053| -------- | ------------------------- | ---- | ------------------------------------- | 1054| state | boolean | Yes | Scroll switch status. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**. | 1055| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 1056 1057**Example** 1058 1059```js 1060try { 1061 pointer.setTouchpadScrollSwitch(true, (error: Error) => { 1062 if (error) { 1063 console.log(`setTouchpadScrollSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1064 return; 1065 } 1066 console.log(`setTouchpadScrollSwitch success`); 1067 }); 1068} catch (error) { 1069 console.log(`setTouchpadScrollSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1070} 1071``` 1072 1073## pointer.setTouchpadScrollSwitch<sup>10+</sup> 1074 1075setTouchpadScrollSwitch(state: boolean): Promise\<void> 1076 1077Sets the scroll switch of the touchpad. This API uses a promise to return the result. 1078 1079**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1080 1081**System API**: This is a system API. 1082 1083**Parameters** 1084 1085| Name | Type | Mandatory | Description | 1086| ----- | ------ | ---- | ----------------------------------- | 1087| state | boolean| Yes | Scroll switch status. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**.| 1088 1089**Return value** 1090 1091| Name | Description | 1092| ------------------- | ---------------- | 1093| Promise\<void> | Promise used to return the result.| 1094 1095**Example** 1096 1097```js 1098try { 1099 pointer.setTouchpadScrollSwitch(false).then(() => { 1100 console.log(`setTouchpadScrollSwitch success`); 1101 }); 1102} catch (error) { 1103 console.log(`setTouchpadScrollSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1104} 1105``` 1106 1107## pointer.getTouchpadScrollSwitch<sup>10+</sup> 1108 1109getTouchpadScrollSwitch(callback: AsyncCallback\<boolean>): void 1110 1111Obtains the scroll switch status of the touchpad. This API uses an asynchronous callback to return the result. 1112 1113**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1114 1115**System API**: This is a system API. 1116 1117**Parameters** 1118 1119| Name | Type | Mandatory | Description | 1120| -------- | --------------------------- | ---- | -------------- | 1121| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**.| 1122 1123**Example** 1124 1125```js 1126try { 1127 pointer.getTouchpadScrollSwitch((error: Error, state: boolean) => { 1128 console.log(`getTouchpadScrollSwitch success, state: ${JSON.stringify(state)}`); 1129 }); 1130} catch (error) { 1131 console.log(`getTouchpadScrollSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1132} 1133``` 1134 1135## pointer.getTouchpadScrollSwitch<sup>10+</sup> 1136 1137getTouchpadScrollSwitch(): Promise\<boolean> 1138 1139Obtains the scroll switch status of the touchpad. This API uses a promise to return the result. 1140 1141**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1142 1143**System API**: This is a system API. 1144 1145**Return value** 1146 1147| Name | Description | 1148| --------------------- | ------------------- | 1149| Promise\<boolean> | Promise used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**.| 1150 1151**Example** 1152 1153```js 1154try { 1155 pointer.getTouchpadScrollSwitch().then((state) => { 1156 console.log(`getTouchpadScrollSwitch success, state: ${JSON.stringify(state)}`); 1157 }); 1158} catch (error) { 1159 console.log(`getTouchpadScrollSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1160} 1161``` 1162 1163## pointer.setTouchpadScrollDirection<sup>10+</sup> 1164 1165setTouchpadScrollDirection(state: boolean, callback: AsyncCallback\<void>): void 1166 1167Sets the scroll direction of the touchpad. This API uses an asynchronous callback to return the result. 1168 1169**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1170 1171**System API**: This is a system API. 1172 1173**Parameters** 1174 1175| Name | Type | Mandatory | Description | 1176| -------- | ------------------------- | ---- | ------------------------------------- | 1177| state | boolean | Yes | Scroll direction of the touchpad.<br>The value **true** indicates that the scroll direction is the same as the finger moving direction, and the value **false** indicates the opposite.<br>The default value is **true**. | 1178| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 1179 1180**Example** 1181 1182```js 1183try { 1184 pointer.setTouchpadScrollDirection(true, (error: Error) => { 1185 if (error) { 1186 console.log(`setTouchpadScrollDirection failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1187 return; 1188 } 1189 console.log(`setTouchpadScrollDirection success`); 1190 }); 1191} catch (error) { 1192 console.log(`setTouchpadScrollDirection failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1193} 1194``` 1195 1196## pointer.setTouchpadScrollDirection<sup>10+</sup> 1197 1198setTouchpadScrollDirection(state: boolean): Promise\<void> 1199 1200Sets the scroll direction of the touchpad. This API uses a promise to return the result. 1201 1202**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1203 1204**System API**: This is a system API. 1205 1206**Parameters** 1207 1208| Name | Type | Mandatory | Description | 1209| ----- | ------ | ---- | ----------------------------------- | 1210| state | boolean| Yes | Scroll direction of the touchpad.<br>The value **true** indicates that the scroll direction is the same as the finger moving direction, and the value **false** indicates the opposite.<br>The default value is **true**.| 1211 1212**Return value** 1213 1214| Name | Description | 1215| ------------------- | ---------------- | 1216| Promise\<void> | Promise used to return the result.| 1217 1218**Example** 1219 1220```js 1221try { 1222 pointer.setTouchpadScrollDirection (false).then(() => { 1223 console.log(`setTouchpadScrollDirection success`); 1224 }); 1225} catch (error) { 1226 console.log(`setTouchpadScrollDirection failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1227} 1228``` 1229 1230## pointer.getTouchpadScrollDirection<sup>10+</sup> 1231 1232getTouchpadScrollDirection(callback: AsyncCallback\<boolean>): void 1233 1234Obtains the scroll direction of the touchpad. This API uses an asynchronous callback to return the result. 1235 1236**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1237 1238**System API**: This is a system API. 1239 1240**Parameters** 1241 1242| Name | Type | Mandatory | Description | 1243| -------- | --------------------------- | ---- | -------------- | 1244| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>The value **true** indicates that the scroll direction is the same as the finger moving direction, and the value **false** indicates the opposite.<br>The default value is **true**.| 1245 1246**Example** 1247 1248```js 1249try { 1250 pointer.getTouchpadScrollDirection ((error: Error, state: boolean) => { 1251 console.log(`getTouchpadScrollDirection success, state: ${JSON.stringify(state)}`); 1252 }); 1253} catch (error) { 1254 console.log(`getTouchpadScrollDirection failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1255} 1256``` 1257 1258## pointer.getTouchpadScrollDirection<sup>10+</sup> 1259 1260getTouchpadScrollDirection(): Promise\<boolean> 1261 1262Obtains the scroll direction of the touchpad. This API uses a promise to return the result. 1263 1264**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1265 1266**System API**: This is a system API. 1267 1268**Return value** 1269 1270| Name | Description | 1271| --------------------- | ------------------- | 1272| Promise\<boolean> | Promise used to return the result.<br>The value **true** indicates that the scroll direction is the same as the finger moving direction, and the value **false** indicates the opposite.<br>The default value is **true**.| 1273 1274**Example** 1275 1276```js 1277try { 1278 pointer.getTouchpadScrollDirection().then((state: boolean) => { 1279 console.log(`getTouchpadScrollDirection success, state: ${JSON.stringify(state)}`); 1280 }); 1281} catch (error) { 1282 console.log(`getTouchpadScrollDirection failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1283} 1284``` 1285 1286## pointer.setTouchpadTapSwitch<sup>10+</sup> 1287 1288setTouchpadTapSwitch(state: boolean, callback: AsyncCallback\<void>): void 1289 1290Sets the tap switch of the touchpad. This API uses an asynchronous callback to return the result. 1291 1292**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1293 1294**System API**: This is a system API. 1295 1296**Parameters** 1297 1298| Name | Type | Mandatory | Description | 1299| -------- | ------------------------- | ---- | ------------------------------------- | 1300| state | boolean | Yes |Tap switch status of the touchpad The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**. | 1301| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 1302 1303**Example** 1304 1305```js 1306try { 1307 pointer.setTouchpadTapSwitch(true, (error: Error) => { 1308 if (error) { 1309 console.log(`setTouchpadTapSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1310 return; 1311 } 1312 console.log(`setTouchpadTapSwitch success`); 1313 }); 1314} catch (error) { 1315 console.log(`setTouchpadTapSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1316} 1317``` 1318 1319## pointer.setTouchpadTapSwitch <sup>10+</sup> 1320 1321setTouchpadTapSwitch(state: boolean): Promise\<void> 1322 1323Sets the tap switch of the touchpad. This API uses a promise to return the result. 1324 1325**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1326 1327**System API**: This is a system API. 1328 1329**Parameters** 1330 1331| Name | Type | Mandatory | Description | 1332| ----- | ------ | ---- | ----------------------------------- | 1333| state | boolean| Yes | Tap switch status of the touchpad. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**. | 1334 1335**Return value** 1336 1337| Name | Description | 1338| ------------------- | ---------------- | 1339| Promise\<void> | Promise used to return the result.| 1340 1341**Example** 1342 1343```js 1344try { 1345 pointer.setTouchpadTapSwitch(false).then(() => { 1346 console.log(`setTouchpadTapSwitch success`); 1347 }); 1348} catch (error) { 1349 console.log(`setTouchpadTapSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1350} 1351``` 1352 1353## pointer.getTouchpadTapSwitch<sup>10+</sup> 1354 1355getTouchpadTapSwitch(callback: AsyncCallback\<boolean>): void 1356 1357Obtains the tap switch status of the touchpad. This API uses an asynchronous callback to return the result. 1358 1359**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1360 1361**System API**: This is a system API. 1362 1363**Parameters** 1364 1365| Name | Type | Mandatory | Description | 1366| -------- | --------------------------- | ---- | -------------- | 1367| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**.| 1368 1369**Example** 1370 1371```js 1372try { 1373 pointer.getTouchpadTapSwitch((error: Error, state: boolean) => { 1374 console.log(`getTouchpadTapSwitch success, state: ${JSON.stringify(state)}`); 1375 }); 1376} catch (error) { 1377 console.log(`getTouchpadTapSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1378} 1379``` 1380 1381## pointer.getTouchpadTapSwitch<sup>10+</sup> 1382 1383getTouchpadTapSwitch(): Promise\<boolean> 1384 1385Obtains the tap switch status of the touchpad. This API uses a promise to return the result. 1386 1387**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1388 1389**System API**: This is a system API. 1390 1391**Return value** 1392 1393| Name | Description | 1394| --------------------- | ------------------- | 1395| Promise\<boolean> | Promise used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**.| 1396 1397**Example** 1398 1399```js 1400try { 1401 pointer.getTouchpadTapSwitch().then((state: boolean) => { 1402 console.log(`getTouchpadTapSwitch success, state: ${JSON.stringify(state)}`); 1403 }); 1404} catch (error) { 1405 console.log(`getTouchpadTapSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1406} 1407``` 1408 1409## pointer.setTouchpadPointerSpeed<sup>10+</sup> 1410 1411setTouchpadPointerSpeed(speed: number, callback: AsyncCallback\<void>): void 1412 1413Sets the mouse pointer moving speed of the touchpad. This API uses an asynchronous callback to return the result. 1414 1415**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1416 1417**System API**: This is a system API. 1418 1419**Parameters** 1420 1421| Name | Type | Mandatory | Description | 1422| -------- | ------------------------- | ---- | ------------------------------------- | 1423| speed | number | Yes |Mouse pointer moving speed of the touchpad. The value range is [1,11]. The default value is **5**. | 1424| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 1425 1426**Example** 1427 1428```js 1429try { 1430 pointer.setTouchpadPointerSpeed(1, (error: Error) => { 1431 if (error) { 1432 console.log(`setTouchpadPointerSpeedfailed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1433 return; 1434 } 1435 console.log(`setTouchpadPointerSpeed success`); 1436 }); 1437} catch (error) { 1438 console.log(`setTouchpadPointerSpeed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1439} 1440``` 1441 1442## pointer.setTouchpadPointerSpeed<sup>10+</sup> 1443 1444setTouchpadPointerSpeed(speed: number): Promise\<void> 1445 1446Sets the mouse pointer moving speed of the touchpad. This API uses a promise to return the result. 1447 1448**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1449 1450**System API**: This is a system API. 1451 1452**Parameters** 1453 1454| Name | Type | Mandatory | Description | 1455| ----- | ------ | ---- | ----------------------------------- | 1456| speed| number | Yes | Mouse pointer moving speed of the touchpad. The value range is [1,11]. The default value is **5**. | 1457 1458**Return value** 1459 1460| Name | Description | 1461| ------------------- | ---------------- | 1462| Promise\<void> | Promise used to return the result.| 1463 1464**Example** 1465 1466```js 1467try { 1468 pointer.setTouchpadPointerSpeed(10).then(() => { 1469 console.log(`setTouchpadPointerSpeed success`); 1470 }); 1471} catch (error) { 1472 console.log(`setTouchpadPointerSpeed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1473} 1474``` 1475 1476## pointer.getTouchpadPointerSpeed<sup>10+</sup> 1477 1478getTouchpadPointerSpeed(callback: AsyncCallback\<number>): void 1479 1480Obtains the mouse pointer moving speed of the touchpad. This API uses an asynchronous callback to return the result. 1481 1482**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1483 1484**System API**: This is a system API. 1485 1486**Parameters** 1487 1488| Name | Type | Mandatory | Description | 1489| -------- | --------------------------- | ---- | -------------- | 1490| callback | AsyncCallback\<number> | Yes | Callback used to return the result.| 1491 1492**Example** 1493 1494```js 1495try { 1496 pointer.getTouchpadPointerSpeed((error: Error, speed: number) => { 1497 console.log(`getTouchpadPointerSpeed success, speed: ${JSON.stringify(speed)}`); 1498 }); 1499} catch (error) { 1500 console.log(`getTouchpadPointerSpeed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1501} 1502``` 1503 1504## pointer.getTouchpadPointerSpeed<sup>10+</sup> 1505 1506getTouchpadPointerSpeed(): Promise\<number> 1507 1508Obtains the mouse pointer moving speed of the touchpad. This API uses a promise to return the result. 1509 1510**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1511 1512**System API**: This is a system API. 1513 1514**Return value** 1515 1516| Name | Description | 1517| --------------------- | ------------------- | 1518| Promise\<number> | Promise used to return the result.| 1519 1520**Example** 1521 1522```js 1523try { 1524 pointer.getTouchpadPointerSpeed().then((speed: number) => { 1525 console.log(`getTouchpadPointerSpeed success, speed: ${JSON.stringify(speed)}`); 1526 }); 1527} catch (error) { 1528 console.log(`getTouchpadPointerSpeed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1529} 1530``` 1531 1532## pointer.setTouchpadPinchSwitch<sup>10+</sup> 1533 1534setTouchpadPinchSwitch(state: boolean, callback: AsyncCallback\<void>): void 1535 1536Sets the pinch switch of the touchpad. This API uses an asynchronous callback to return the result. 1537 1538**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1539 1540**System API**: This is a system API. 1541 1542**Parameters** 1543 1544| Name | Type | Mandatory | Description | 1545| -------- | ------------------------- | ---- | ------------------------------------- | 1546| state | boolean | Yes |Pinch switch status of the touchpad. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**. | 1547| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 1548 1549**Example** 1550 1551```js 1552try { 1553 pointer.setTouchpadTapSwitch(true, (error: Error) => { 1554 if (error) { 1555 console.log(`setTouchpadPinchSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1556 return; 1557 } 1558 console.log(`setTouchpadPinchSwitch success`); 1559 }); 1560} catch (error) { 1561 console.log(`setTouchpadPinchSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1562} 1563``` 1564 1565## pointer.setTouchpadPinchSwitch<sup>10+</sup> 1566 1567setTouchpadPinchSwitch(state: boolean): Promise\<void> 1568 1569Sets the pinch switch of the touchpad. This API uses a promise to return the result. 1570 1571**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1572 1573**System API**: This is a system API. 1574 1575**Parameters** 1576 1577| Name | Type | Mandatory | Description | 1578| ----- | ------ | ---- | ----------------------------------- | 1579| state | boolean| Yes | Pinch switch status of the touchpad. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**. | 1580 1581**Return value** 1582 1583| Name | Description | 1584| ------------------- | ---------------- | 1585| Promise\<void> | Promise used to return the result.| 1586 1587**Example** 1588 1589```js 1590try { 1591 pointer.setTouchpadPinchSwitch(false).then(() => { 1592 console.log(`setTouchpadPinchSwitch success`); 1593 }); 1594} catch (error) { 1595 console.log(`setTouchpadPinchSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1596} 1597``` 1598 1599## pointer.getTouchpadPinchSwitch<sup>10+</sup> 1600 1601getTouchpadPinchSwitch(callback: AsyncCallback\<boolean>): void 1602 1603Obtains the pinch switch status of the touchpad. This API uses an asynchronous callback to return the result. 1604 1605**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1606 1607**System API**: This is a system API. 1608 1609**Parameters** 1610 1611| Name | Type | Mandatory | Description | 1612| -------- | --------------------------- | ---- | -------------- | 1613| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**.| 1614 1615**Example** 1616 1617```js 1618try { 1619 pointer.getTouchpadPinchSwitch((error: Error, state: boolean) => { 1620 console.log(`getTouchpadPinchSwitch success, state: ${JSON.stringify(state)}`); 1621 }); 1622} catch (error) { 1623 console.log(`getTouchpadPinchSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1624} 1625``` 1626 1627## pointer.getTouchpadPinchSwitch<sup>10+</sup> 1628 1629getTouchpadPinchSwitch(): Promise\<boolean> 1630 1631Obtains the pinch switch status of the touchpad. This API uses a promise to return the result. 1632 1633**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1634 1635**System API**: This is a system API. 1636 1637**Return value** 1638 1639| Name | Description | 1640| --------------------- | ------------------- | 1641| Promise\<boolean> | Promise used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**.| 1642 1643**Example** 1644 1645```js 1646try { 1647 pointer.getTouchpadPinchSwitch().then((state: boolean) => { 1648 console.log(`getTouchpadPinchSwitch success, state: ${JSON.stringify(state)}`); 1649 }); 1650} catch (error) { 1651 console.log(`getTouchpadPinchSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1652} 1653``` 1654 1655## pointer.setTouchpadSwipeSwitch<sup>10+</sup> 1656 1657setTouchpadSwipeSwitch(state: boolean, callback: AsyncCallback\<void>): void 1658 1659Sets the multi-finger swipe switch of the touchpad. This API uses an asynchronous callback to return the result. 1660 1661**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1662 1663**System API**: This is a system API. 1664 1665**Parameters** 1666 1667| Name | Type | Mandatory | Description | 1668| -------- | ------------------------- | ---- | ------------------------------------- | 1669| state | boolean | Yes |Swipe switch status of the touchpad. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**. | 1670| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 1671 1672**Example** 1673 1674```js 1675try { 1676 pointer.setTouchpadSwipeSwitch(true, (error: Error) => { 1677 if (error) { 1678 console.log(`setTouchpadSwipeSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1679 return; 1680 } 1681 console.log(`setTouchpadSwipeSwitch success`); 1682 }); 1683} catch (error) { 1684 console.log(`setTouchpadSwipeSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1685} 1686``` 1687 1688## pointer.setTouchpadSwipeSwitch<sup>10+</sup> 1689 1690setTouchpadSwipeSwitch(state: boolean): Promise\<void> 1691 1692Sets the swipe switch of the touchpad. This API uses a promise to return the result. 1693 1694**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1695 1696**System API**: This is a system API. 1697 1698**Parameters** 1699 1700| Name | Type | Mandatory | Description | 1701| ----- | ------ | ---- | ----------------------------------- | 1702| state | boolean| Yes | Swipe switch status of the touchpad. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**. | 1703 1704**Return value** 1705 1706| Name | Description | 1707| ------------------- | ---------------- | 1708| Promise\<void> | Promise used to return the result.| 1709 1710**Example** 1711 1712```js 1713try { 1714 pointer.setTouchpadSwipeSwitch(false).then(() => { 1715 console.log(`setTouchpadSwipeSwitch success`); 1716 }); 1717} catch (error) { 1718 console.log(`setTouchpadSwipeSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1719} 1720``` 1721 1722## pointer.getTouchpadSwipeSwitch<sup>10+</sup> 1723 1724getTouchpadSwipeSwitch(callback: AsyncCallback\<boolean>): void 1725 1726Obtains the multi-finger swipe switch status of the touchpad. This API uses an asynchronous callback to return the result. 1727 1728**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1729 1730**System API**: This is a system API. 1731 1732**Parameters** 1733 1734| Name | Type | Mandatory | Description | 1735| -------- | --------------------------- | ---- | -------------- | 1736| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**.| 1737 1738**Example** 1739 1740```js 1741try { 1742 pointer.getTouchpadSwipeSwitch((error: Error, state: boolean) => { 1743 console.log(`getTouchpadSwipeSwitch success, state: ${JSON.stringify(state)}`); 1744 }); 1745} catch (error) { 1746 console.log(`getTouchpadSwipeSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1747} 1748``` 1749 1750## pointer.getTouchpadSwipeSwitch<sup>10+</sup> 1751 1752getTouchpadSwipeSwitch(): Promise\<boolean> 1753 1754Obtains the multi-finger swipe switch status of the touchpad. This API uses a promise to return the result. 1755 1756**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1757 1758**System API**: This is a system API. 1759 1760**Return value** 1761 1762| Name | Description | 1763| --------------------- | ------------------- | 1764| Promise\<boolean> | Promise used to return the result. The value **true** indicates that the switch is enabled, and the value **false** indicates the opposite. The default value is **true**.| 1765 1766**Example** 1767 1768```js 1769try { 1770 pointer.getTouchpadSwipeSwitch().then((state: boolean) => { 1771 console.log(`getTouchpadSwipeSwitch success, state: ${JSON.stringify(state)}`); 1772 }); 1773} catch (error) { 1774 console.log(`getTouchpadSwipeSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1775} 1776``` 1777 1778## RightClickType<sup>10+</sup> 1779 1780Enumerates shortcut menu triggering modes. 1781 1782**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1783 1784| Name | Value | Description | 1785| -------------------------------- | ---- | ------ | 1786| TOUCHPAD_RIGHT_BUTTON | 1 |Tapping the right-button area of the touchpad.| 1787| TOUCHPAD_LEFT_BUTTON | 2 |Tapping the left-button area of the touchpad.| 1788| TOUCHPAD_TWO_FINGER_TAP | 3 |Tapping or pressing the touchpad with two fingers.| 1789 1790## pointer.setTouchpadRightClickType<sup>10+</sup> 1791 1792setTouchpadRightClickType(type: RightClickType, callback: AsyncCallback\<void>): void 1793 1794Sets the shortcut menu type of the touchpad. This API uses an asynchronous callback to return the result. 1795 1796**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1797 1798**System API**: This is a system API. 1799 1800**Parameters** 1801 1802| Name | Type | Mandatory | Description | 1803| -------- | ------------------------- | ---- | ------------------------------------- | 1804| type| [RightClickType](#rightclicktype10)| Yes |Shortcut menu type of the touchpad.<br>- TOUCHPAD_RIGHT_BUTTON: tapping the right-button area of the touchpad.<br>- TOUCHPAD_LEFT_BUTTON: tapping the left-button area of the touchpad.<br>- TOUCHPAD_TWO_FINGER_TAP: tapping or pressing the touchpad with two fingers.<br>The default value is **TOUCHPAD_RIGHT_BUTTON**. | 1805| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 1806 1807**Example** 1808 1809```js 1810try { 1811 pointer.setTouchpadRightClickType(pointer.RightClickType.TOUCHPAD_RIGHT_BUTTON , (error: Error) => { 1812 if (error) { 1813 console.log(`setTouchpadRightClickType, error: ${JSON.stringify(error, [`code`, `message`])}`); 1814 return; 1815 } 1816 console.log(`setTouchpadRightClickType success`); 1817 }); 1818} catch (error) { 1819 console.log(`setTouchpadRightClickType failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1820} 1821``` 1822 1823## pointer.setTouchpadRightClickType<sup>10+</sup> 1824 1825setTouchpadRightClickType(type: RightClickType): Promise\<void> 1826 1827Sets the shortcut menu type of the touchpad. This API uses a promise to return the result. 1828 1829**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1830 1831**System API**: This is a system API. 1832 1833**Parameters** 1834 1835| Name | Type | Mandatory | Description | 1836| ----- | ------ | ---- | ----------------------------------- | 1837| type| [RightClickType](#rightclicktype10)| Yes | Shortcut menu type of the touchpad.<br>- TOUCHPAD_RIGHT_BUTTON: tapping the right-button area of the touchpad.<br>- TOUCHPAD_LEFT_BUTTON: tapping the left-button area of the touchpad.<br>- TOUCHPAD_TWO_FINGER_TAP: tapping or pressing the touchpad with two fingers.<br>The default value is **TOUCHPAD_RIGHT_BUTTON**.| 1838 1839**Return value** 1840 1841| Name | Description | 1842| ------------------- | ---------------- | 1843| Promise\<void> | Promise used to return the result.| 1844 1845**Example** 1846 1847```js 1848try { 1849 pointer.setTouchpadRightClickType(pointer.RightClickType.TOUCHPAD_RIGHT_BUTTON).then(() => { 1850 console.log(`setTouchpadRightClickType success`); 1851 }); 1852} catch (error) { 1853 console.log(`setTouchpadRightClickType failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1854} 1855``` 1856 1857## pointer.getTouchpadRightClickType<sup>10+</sup> 1858 1859getTouchpadRightClickType(callback: AsyncCallback\<RightClickType>): void 1860 1861Obtains the shortcut menu type of the touchpad. This API uses an asynchronous callback to return the result. 1862 1863**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1864 1865**System API**: This is a system API. 1866 1867**Parameters** 1868 1869| Name | Type | Mandatory | Description | 1870| -------- | --------------------------- | ---- | -------------- | 1871| callback | AsyncCallback\<[RightClickType](#rightclicktype10)> | Yes | Callback used to return the result.| 1872 1873**Example** 1874 1875```js 1876try { 1877 pointer.getTouchpadRightClickType((error: Error, type: pointer.RightClickType) => { 1878 console.log(`getTouchpadRightClickType success, type: ${JSON.stringify(type)}`); 1879 }); 1880} catch (error) { 1881 console.log(`getTouchpadRightClickType failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1882} 1883``` 1884 1885## pointer.getTouchpadRightClickType<sup>10+</sup> 1886 1887getTouchpadRightClickType(): Promise\<RightClickType> 1888 1889Obtains the shortcut menu type of the touchpad. This API uses a promise to return the result. 1890 1891**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1892 1893**System API**: This is a system API. 1894 1895**Return value** 1896 1897| Name | Description | 1898| --------------------- | ------------------- | 1899| Promise\<[RightClickType](#rightclicktype10) > | Promise used to return the result.| 1900 1901**Example** 1902 1903```js 1904try { 1905 pointer.getTouchpadRightClickType().then((type: pointer.RightClickType) => { 1906 console.log(`getTouchpadRightClickType success, typeed: ${JSON.stringify(type)}`); 1907 }); 1908} catch (error) { 1909 console.log(`getTouchpadRightClickType failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1910} 1911``` 1912 1913## pointer.setPointerSize<sup>10+</sup> 1914 1915setPointerSize(size: number, callback: AsyncCallback<void>): void 1916 1917Sets the pointer size. This API uses an asynchronous callback to return the result. 1918 1919**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1920 1921**System API**: This is a system API. 1922 1923**Parameters** 1924 1925| Name | Type | Mandatory | Description | 1926| -------- | ------------------------- | ---- | ------------------------------------- | 1927| size | number | Yes | Pointer size. The value ranges from **1** to **7**. The default value is **1**. | 1928| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| 1929 1930**Example** 1931 1932```js 1933try { 1934 pointer.setPointerSize(1, (error: Error) => { 1935 if (error) { 1936 console.log(`setPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1937 return; 1938 } 1939 console.log(`setPointerSize success`); 1940 }); 1941} catch (error) { 1942 console.log(`setPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1943} 1944``` 1945 1946## pointer.setPointerSize<sup>10+</sup> 1947 1948setPointerSize(size: number): Promise<void> 1949 1950Sets the pointer size. This API uses a promise to return the result. 1951 1952**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1953 1954**System API**: This is a system API. 1955 1956**Parameters** 1957 1958| Name | Type | Mandatory | Description | 1959| ----- | ------ | ---- | ----------------------------------- | 1960| size | number | Yes | Pointer size. The value ranges from **1** to **7**. The default value is **1**.| 1961 1962**Return value** 1963 1964| Name | Description | 1965| ------------------- | ---------------- | 1966| Promise<void> | Promise that returns no value.| 1967 1968**Example** 1969 1970```js 1971try { 1972 pointer.setPointerSize(3).then(() => { 1973 console.log(`setPointerSize success`); 1974 }); 1975} catch (error) { 1976 console.log(`setPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 1977} 1978``` 1979 1980## pointer.setPointerSizeSync<sup>10+</sup> 1981 1982setPointerSizeSync(size: number): void; 1983 1984Sets the pointer size. This API returns the result synchronously. 1985 1986**System capability**: SystemCapability.MultimodalInput.Input.Pointer 1987 1988**System API**: This is a system API. 1989 1990**Parameters** 1991 1992| Name | Type | Mandatory | Description | 1993| ----- | ------ | ---- | ----------------------------------- | 1994| size | number | Yes | Pointer size. The value ranges from **1** to **7**. The default value is **1**.| 1995 1996**Example** 1997 1998```js 1999try { 2000 pointer.setPointerSizeSync(5); 2001 console.log(`setPointerSizeSync success`); 2002} catch (error) { 2003 console.log(`setPointerSizeSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2004} 2005``` 2006 2007## pointer.getPointerSize<sup>10+</sup> 2008 2009getPointerSize(callback: AsyncCallback<number>): void 2010 2011Obtains the pointer size. This API uses an asynchronous callback to return the result. 2012 2013**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2014 2015**System API**: This is a system API. 2016 2017**Parameters** 2018 2019| Name | Type | Mandatory | Description | 2020| -------- | --------------------------- | ---- | -------------- | 2021| callback | AsyncCallback<number> | Yes | Callback used to return the result.| 2022 2023**Example** 2024 2025```js 2026try { 2027 pointer.getPointerSize((error: Error, size: number) => { 2028 console.log(`getPointerSize success, size: ${JSON.stringify(size)}`); 2029 }); 2030} catch (error) { 2031 console.log(`getPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2032} 2033``` 2034 2035## pointer.getPointerSize<sup>10+</sup> 2036 2037getPointerSize(): Promise<number> 2038 2039Obtains the pointer size. This API uses a promise to return the result. 2040 2041**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2042 2043**System API**: This is a system API. 2044 2045**Return value** 2046 2047| Name | Description | 2048| --------------------- | ------------------- | 2049| Promise<number> | Promise used to return the result.| 2050 2051**Example** 2052 2053```js 2054try { 2055 pointer.getPointerSize().then((size: number) => { 2056 console.log(`getPointerSize success, size: ${JSON.stringify(size)}`); 2057 }); 2058} catch (error) { 2059 console.log(`getPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2060} 2061``` 2062 2063## pointer.getPointerSizeSync<sup>10+</sup> 2064 2065getPointerSizeSync(): number 2066 2067Obtains the pointer size. This API returns the result synchronously. 2068 2069**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2070 2071**System API**: This is a system API. 2072 2073**Return value** 2074 2075| Name | Description | 2076| --------------------- | ------------------- | 2077| number | Pointer size. | 2078 2079**Example** 2080 2081```js 2082try { 2083 let pointerSize = pointer.getPointerSizeSync(); 2084 console.log(`getPointerSizeSync success, pointerSize: ${JSON.stringify(pointerSize)}`); 2085} catch (error) { 2086 console.log(`getPointerSizeSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2087} 2088``` 2089 2090## pointer.setPointerColor<sup>10+</sup> 2091 2092setPointerColor(color: number, callback: AsyncCallback<void>): void 2093 2094Sets the pointer color. This API uses an asynchronous callback to return the result. 2095 2096**NOTE** 2097> 2098> When performing this operation, you need to connect an external device, such as a mouse or Bluetooth device. 2099 2100**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2101 2102**System API**: This is a system API. 2103 2104**Parameters** 2105 2106| Name | Type | Mandatory | Description | 2107| -------- | ------------------------- | ---- | ------------------------------------- | 2108| color | number | Yes | Pointer color. The default value is **black** (0x000000). | 2109| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| 2110 2111**Example** 2112 2113```js 2114try { 2115 pointer.setPointerColor(0xF6C800, (error: Error) => { 2116 if (error) { 2117 console.log(`setPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2118 return; 2119 } 2120 console.log(`setPointerColor success`); 2121 }); 2122} catch (error) { 2123 console.log(`setPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2124} 2125``` 2126 2127## pointer.setPointerColor<sup>10+</sup> 2128 2129setPointerColor(color: number): Promise<void> 2130 2131Sets the pointer color. This API uses a promise to return the result. 2132 2133**NOTE** 2134> 2135> When performing this operation, you need to connect an external device, such as a mouse or Bluetooth device. 2136 2137**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2138 2139**System API**: This is a system API. 2140 2141**Parameters** 2142 2143| Name | Type | Mandatory | Description | 2144| ----- | ------ | ---- | ----------------------------------- | 2145| color | number | Yes | Pointer color. The default value is **black** (0x000000).| 2146 2147**Return value** 2148 2149| Name | Description | 2150| ------------------- | ---------------- | 2151| Promise<void> | Promise that returns no value.| 2152 2153**Example** 2154 2155```js 2156try { 2157 pointer.setPointerColor(0xF6C800).then(() => { 2158 console.log(`setPointerColor success`); 2159 }); 2160} catch (error) { 2161 console.log(`setPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2162} 2163``` 2164 2165## pointer.setPointerColorSync<sup>10+</sup> 2166 2167setPointerColorSync(color: number): void; 2168 2169Sets the pointer color. This API returns the result synchronously. 2170 2171**NOTE** 2172> 2173> When performing this operation, you need to connect an external device, such as a mouse or Bluetooth device. 2174 2175**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2176 2177**System API**: This is a system API. 2178 2179**Parameters** 2180 2181| Name | Type | Mandatory | Description | 2182| ----- | ------ | ---- | ----------------------------------- | 2183| color | number | Yes | Pointer color. The default value is **black** (0x000000).| 2184 2185**Example** 2186 2187```js 2188try { 2189 pointer.setPointerColorSync(0xF6C800); 2190 console.log(`setPointerColorSync success`); 2191} catch (error) { 2192 console.log(`setPointerColorSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2193} 2194``` 2195 2196## pointer.getPointerColor<sup>10+</sup> 2197 2198getPointerColor(callback: AsyncCallback<number>): void 2199 2200Obtains the pointer color. This API uses an asynchronous callback to return the result. 2201 2202**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2203 2204**System API**: This is a system API. 2205 2206**Parameters** 2207 2208| Name | Type | Mandatory | Description | 2209| -------- | --------------------------- | ---- | -------------- | 2210| callback | AsyncCallback<number> | Yes | Callback used to return the result.| 2211 2212**Example** 2213 2214```js 2215try { 2216 pointer.getPointerColor((error: Error, color: number) => { 2217 console.log(`getPointerColor success, color: ${JSON.stringify(color)}`); 2218 }); 2219} catch (error) { 2220 console.log(`getPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2221} 2222``` 2223 2224## pointer.getPointerColor<sup>10+</sup> 2225 2226getPointerColor(): Promise<number> 2227 2228Obtains the pointer color. This API uses a promise to return the result. 2229 2230**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2231 2232**System API**: This is a system API. 2233 2234**Return value** 2235 2236| Name | Description | 2237| --------------------- | ------------------- | 2238| Promise<number> | Promise used to return the result.| 2239 2240**Example** 2241 2242```js 2243try { 2244 pointer.getPointerColor().then((color: number) => { 2245 console.log(`getPointerColor success, color: ${JSON.stringify(color)}`); 2246 }); 2247} catch (error) { 2248 console.log(`getPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2249} 2250``` 2251 2252## pointer.getPointerColorSync<sup>10+</sup> 2253 2254getPointerColorSync(): number 2255 2256Obtains the pointer color. This API returns the result synchronously. 2257 2258**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2259 2260**System API**: This is a system API. 2261 2262**Return value** 2263 2264| Name | Description | 2265| --------------------- | ------------------- | 2266| number | Pointer color.| 2267 2268**Example** 2269 2270```js 2271try { 2272 let pointerColor = pointer.getPointerColorSync(); 2273 console.log(`getPointerColorSync success, pointerColor: ${JSON.stringify(pointerColor)}`); 2274} catch (error) { 2275 console.log(`getPointerColorSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2276} 2277``` 2278 2279## pointer.setCustomCursor<sup>11+</sup> 2280 2281setCustomCursor(windowId: number, pixelMap: image.PixelMap, focusX?: number, focusY?: number): Promise<void> 2282 2283Sets a custom cursor. This API uses a promise to return the result. 2284 2285**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2286 2287**Parameters** 2288 2289| Name | Type | Mandatory | Description | 2290| ----- | ------ | ---- | ----------------------------------- | 2291| windowId | number | Yes | Window ID. | 2292| pixelMap | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Pixel map resource.| 2293| focusX | number | No | Focus x of the custom cursor. The value is greater than or equal to **0**. The default value is **0**.| 2294| focusY | number | No | Focus y of the custom cursor. The value is greater than or equal to **0**. The default value is **0**.| 2295 2296**Return value** 2297 2298| Name | Description | 2299| ------------------- | ---------------- | 2300| Promise<void> | Promise that returns no value.| 2301 2302**Example** 2303 2304```js 2305import image from '@ohos.multimedia.image'; 2306import window from '@ohos.window'; 2307import { BusinessError } from '@ohos.base'; 2308const svgFileData = getContext().resourceManager.getMediaContent($r("app.media.icon")); 2309const svgBuffer = svgFileData.buffer; 2310let svgImagesource: image.ImageSource = image.createImageSource(svgBuffer); 2311let svgDecodingOptions: image.DecodingOptions = {desiredSize: { width: 50, height:50 }}; 2312svgImagesource.createPixelMap(svgDecodingOptions).then((pixelMap) => { 2313 window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => { 2314 let windowId = win.getWindowProperties().id; 2315 try { 2316 pointer.setCustomCursor(windowId, pixelMap).then(() => { 2317 console.log(`setCustomCursor success`); 2318 }); 2319 } catch (error) { 2320 console.log(`setCustomCursor failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2321 } 2322 }); 2323}); 2324``` 2325 2326## pointer.setCustomCursorSync<sup>11+</sup> 2327 2328setCustomCursorSync(windowId: number, pixelMap: image.PixelMap, focusX?: number, focusY?: number): void 2329 2330Sets a custom cursor. This API returns the result synchronously. 2331 2332**System capability**: SystemCapability.MultimodalInput.Input.Pointer 2333 2334**Parameters** 2335 2336| Name | Type | Mandatory | Description | 2337| ----- | ------ | ---- | ----------------------------------- | 2338| windowId | number | Yes | Window ID. | 2339| pixelMap | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Pixel map resource.| 2340| focusX | number | No | Focus x of the custom cursor. The value is greater than or equal to **0**. The default value is **0**.| 2341| focusY | number | No | Focus y of the custom cursor. The value is greater than or equal to **0**. The default value is **0**.| 2342 2343**Example** 2344 2345```js 2346import image from '@ohos.multimedia.image'; 2347import window from '@ohos.window'; 2348import { BusinessError } from '@ohos.base'; 2349const svgFileData = getContext().resourceManager.getMediaContent($r("app.media.icon")); 2350const svgBuffer = svgFileData.buffer; 2351let svgImagesource: image.ImageSource = image.createImageSource(svgBuffer); 2352let svgDecodingOptions: image.DecodingOptions = {desiredSize: { width: 50, height:50 }}; 2353svgImagesource.createPixelMap(svgDecodingOptions).then((pixelMap) => { 2354 window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => { 2355 let windowId = win.getWindowProperties().id; 2356 try { 2357 pointer.setCustomCursorSync(windowId, pixelMap, 25, 25); 2358 console.log(`setCustomCursorSync success`); 2359 } catch (error) { 2360 console.log(`setCustomCursorSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 2361 } 2362 }); 2363}); 2364``` 2365