1# @ohos.multimodalInput.pointer (鼠标指针) 2 3鼠标指针管理模块,用于查询和设置鼠标指针相关属性。 4 5> **说明**: 6> 7> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8 9## 导入模块 10 11```js 12import pointer from '@ohos.multimodalInput.pointer'; 13``` 14 15## pointer.setPointerVisible 16 17setPointerVisible(visible: boolean, callback: AsyncCallback<void>): void 18 19设置鼠标指针显示或者隐藏,使用AsyncCallback异步方式返回结果。 20 21**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 22 23**参数**: 24 25| 参数名 | 类型 | 必填 | 说明 | 26| -------- | ------------------------- | ---- | ---------------------------------------- | 27| visible | boolean | 是 | 鼠标指针是否显示。true表示显示,false表示不显示 | 28| callback | AsyncCallback<void> | 是 | 回调函数。 | 29 30**示例**: 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 50设置鼠标指针显示或者隐藏,使用Promise异步方式返回结果。 51 52**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 53 54**参数**: 55 56| 参数名 | 类型 | 必填 | 说明 | 57| ------- | ------- | ---- | ---------------------------------------- | 58| visible | boolean | 是 | 鼠标指针是否显示。true表示显示,false表示不显示。 | 59 60**返回值**: 61 62| 参数 | 说明 | 63| ------------------- | ------------------- | 64| Promise<void> | Promise对象。 | 65 66**示例**: 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 82使用同步方式设置鼠标指针显示或者隐藏。 83 84**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 85 86**参数**: 87 88| 参数名 | 类型 | 必填 | 说明 | 89| ------- | ------- | ---- | ---------------------------------------- | 90| visible | boolean | 是 | 鼠标指针是否显示。true表示显示,false表示不显示。 | 91 92**示例**: 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 107获取鼠标指针显示或隐藏状态,使用AsyncCallback异步方式返回结果。 108 109**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 110 111**参数**: 112 113| 参数名 | 类型 | 必填 | 说明 | 114| -------- | ---------------------------- | ---- | -------------- | 115| callback | AsyncCallback<boolean> | 是 | 回调函数,异步返回鼠标指针状态,true为显示,false为隐藏。 | 116 117**示例**: 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 137获取鼠标指针显示或隐藏状态,使用Promise异步方式返回结果。 138 139**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 140 141**返回值**: 142 143| 参数 | 说明 | 144| ---------------------- | ------------------- | 145| Promise<boolean> | Promise对象,异步返回鼠标指针显示或隐藏状态。 | 146 147**示例**: 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 163使用同步方式获取鼠标指针显示或者隐藏。 164 165**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 166 167**返回值**: 168 169| 参数 | 说明 | 170| ---------------------- | ------------------- | 171| boolean | 返回鼠标指针显示或隐藏状态。true代表显示状态,false代表隐藏状态。 | 172 173**示例**: 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 188设置鼠标移动速度,使用AsyncCallback异步方式返回结果。 189 190**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 191 192**系统API**: 此接口为系统接口。 193 194**参数**: 195 196| 参数名 | 类型 | 必填 | 说明 | 197| -------- | ------------------------- | ---- | ------------------------------------- | 198| speed | number | 是 | 鼠标移动速度,范围1-11,默认为5。 | 199| callback | AsyncCallback<void> | 是 | 回调函数。 | 200 201**示例**: 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 221设置鼠标移动速度,使用Promise异步方式返回结果。 222 223**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 224 225**系统API**: 此接口为系统接口。 226 227**参数**: 228 229| 参数名 | 类型 | 必填 | 说明 | 230| ----- | ------ | ---- | ----------------------------------- | 231| speed | number | 是 | 鼠标移动速度,范围1-11,默认为5。 | 232 233**返回值**: 234 235| 参数 | 说明 | 236| ------------------- | ---------------- | 237| Promise<void> | Promise对象。 | 238 239**示例**: 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 255使用同步方式设置鼠标移动速度。 256 257**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 258 259**系统API**: 此接口为系统接口。 260 261**参数**: 262 263| 参数名 | 类型 | 必填 | 说明 | 264| ----- | ------ | ---- | ----------------------------------- | 265| speed | number | 是 | 鼠标移动速度,范围1-11,默认为5。 | 266 267**示例**: 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 282获取鼠标移动速度,使用AsyncCallback异步方式返回结果。 283 284**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 285 286**系统API**: 此接口为系统接口。 287 288**参数**: 289 290| 参数名 | 类型 | 必填 | 说明 | 291| -------- | --------------------------- | ---- | -------------- | 292| callback | AsyncCallback<number> | 是 | 回调函数,异步返回鼠标移动速度。 | 293 294**示例**: 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 314获取当前鼠标移动速度,使用Promise异步方式返回结果。 315 316**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 317 318**系统API**: 此接口为系统接口。 319 320**返回值**: 321 322| 参数 | 说明 | 323| --------------------- | ------------------- | 324| Promise<number> | Promise实例,异步返回鼠标移动速度。 | 325 326**示例**: 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 342使用同步方式获取当前鼠标移动速度。 343 344**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 345 346**系统API**: 此接口为系统接口。 347 348**返回值**: 349 350| 参数 | 说明 | 351| --------------------- | ------------------- | 352| number | 返回鼠标移动速度。 | 353 354**示例**: 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 369设置鼠标悬停滚动开关状态,使用AsyncCallback异步方式返回结果。 370 371**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 372 373**系统API**: 此接口为系统接口。 374 375**参数**: 376 377| 参数名 | 类型 | 必填 | 说明 | 378| -------- | ------------------------- | ---- | ------------------------------------- | 379| state | boolean | 是 | 鼠标悬停滚动开关状态。true代表开关开启,false代表开关关闭,默认开启。 | 380| callback | AsyncCallback<void> | 是 | 回调函数。 | 381 382**示例**: 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 402设置鼠标悬停滚动开关状态,使用Promise异步方式返回结果。 403 404**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 405 406**系统API**: 此接口为系统接口。 407 408**参数**: 409 410| 参数名 | 类型 | 必填 | 说明 | 411| ----- | ------ | ---- | ----------------------------------- | 412| state | boolean | 是 | 鼠标悬停滚动开关状态。true代表开关开启,false代表开关关闭,默认开启。 | 413 414**返回值**: 415 416| 参数 | 说明 | 417| ------------------- | ---------------- | 418| Promise<void> | Promise对象。 | 419 420**示例**: 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 436获取鼠标悬停滚动开关状态,使用AsyncCallback异步方式返回结果。 437 438**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 439 440**系统API**: 此接口为系统接口。 441 442**参数**: 443 444| 参数名 | 类型 | 必填 | 说明 | 445| -------- | --------------------------- | ---- | -------------- | 446| callback | AsyncCallback<boolean> | 是 | 回调函数,异步返回鼠标悬停滚动开关状态。true代表开关开启,false代表开关关闭,默认开启。 | 447 448**示例**: 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 464获取当前鼠标悬停滚动开关状态,使用Promise异步方式返回结果。 465 466**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 467 468**系统API**: 此接口为系统接口。 469 470**返回值**: 471 472| 参数 | 说明 | 473| --------------------- | ------------------- | 474| Promise<boolean> | Promise实例,异步返回鼠标悬停滚动开关状态。true代表开关开启,false代表开关关闭,默认开启。 | 475 476**示例**: 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 492设置鼠标主键,使用AsyncCallback异步方式返回结果。 493 494**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 495 496**系统API**: 此接口为系统接口。 497 498**参数**: 499 500| 参数名 | 类型 | 必填 | 说明 | 501| -------- | ------------------------- | ---- | ------------------------------------- | 502| primary | [PrimaryButton](#primarybutton10) | 是 | 鼠标主键id。 | 503| callback | AsyncCallback<void> | 是 | 回调函数。 | 504 505**示例**: 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 525设置鼠标主键,使用Promise异步方式返回结果。 526 527**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 528 529**系统API**: 此接口为系统接口。 530 531**参数**: 532 533| 参数名 | 类型 | 必填 | 说明 | 534| ----- | ------ | ---- | ----------------------------------- | 535| primary | [PrimaryButton](#primarybutton10) | 是 | 鼠标主键id。 | 536 537**返回值**: 538 539| 参数 | 说明 | 540| ------------------- | ---------------- | 541| Promise<void> | Promise对象。 | 542 543**示例**: 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 559获取当前鼠标主键,使用AsyncCallback异步方式返回结果。 560 561**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 562 563**系统API**: 此接口为系统接口。 564 565**参数**: 566 567| 参数名 | 类型 | 必填 | 说明 | 568| -------- | --------------------------- | ---- | -------------- | 569| callback | AsyncCallback<[PrimaryButton](#primarybutton10)> | 是 | 回调函数,异步返回鼠标主键。 | 570 571**示例**: 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 587获取当前鼠标主键,使用Promise异步方式返回结果。 588 589**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 590 591**系统API**: 此接口为系统接口。 592 593**返回值**: 594 595| 参数 | 说明 | 596| --------------------- | ------------------- | 597| Promise<[PrimaryButton](#primarybutton10)> | Promise实例,异步返回鼠标主键。 | 598 599**示例**: 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 613鼠标主键类型。 614 615**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 616 617| 名称 | 值 | 说明 | 618| -------------------------------- | ---- | ------ | 619| LEFT | 0 | 鼠标左键 | 620| RIGHT | 1 | 鼠标右键 | 621 622## pointer.setMouseScrollRows<sup>10+</sup> 623 624setMouseScrollRows(rows: number, callback: AsyncCallback<void>): void 625 626设置鼠标滚动行数,使用AsyncCallback异步方式返回结果。 627 628**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 629 630**系统API**: 此接口为系统接口。 631 632**参数**: 633 634| 参数名 | 类型 | 必填 | 说明 | 635| -------- | ------------------------- | ---- | ------------------------------------- | 636| rows | number | 是 | 鼠标滚动行数,范围1-100,默认为3。 | 637| callback | AsyncCallback<void> | 是 | 回调函数。 | 638 639**示例**: 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 659设置鼠标滚动行数,使用Promise异步方式返回结果。 660 661**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 662 663**系统API**: 此接口为系统接口。 664 665**参数**: 666 667| 参数名 | 类型 | 必填 | 说明 | 668| ----- | ------ | ---- | ----------------------------------- | 669| rows | number | 是 | 鼠标滚动行数,范围1-100,默认为3。 | 670 671**返回值**: 672 673| 参数 | 说明 | 674| ------------------- | ---------------- | 675| Promise<void> | Promise对象。 | 676 677**示例**: 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 693获取鼠标滚动行数,使用AsyncCallback异步方式返回结果。 694 695**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 696 697**系统API**: 此接口为系统接口。 698 699**参数**: 700 701| 参数名 | 类型 | 必填 | 说明 | 702| -------- | --------------------------- | ---- | -------------- | 703| callback | AsyncCallback<number> | 是 | 回调函数,异步返回鼠标滚动行数。 | 704 705**示例**: 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 721获取当前鼠标滚动行数,使用Promise异步方式返回结果。 722 723**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 724 725**系统API**: 此接口为系统接口。 726 727**返回值**: 728 729| 参数 | 说明 | 730| --------------------- | ------------------- | 731| Promise<number> | Promise实例,异步返回鼠标滚动行数。 | 732 733**示例**: 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 749获取鼠标样式类型,使用AsyncCallback异步方式返回结果。 750 751**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 752 753**参数**: 754 755| 参数名 | 类型 | 必填 | 说明 | 756| -------- | ---------------------------------------- | ---- | -------------- | 757| windowId | number | 是 | 窗口id。 | 758| callback | AsyncCallback<[PointerStyle](#pointerstyle)> | 是 | 回调函数,异步返回鼠标样式类型。 | 759 760**示例**: 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 791获取鼠标样式类型,使用Promise异步方式返回结果。 792 793**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 794 795**参数**: 796 797| 参数名 | 类型 | 必填 | 说明 | 798| -------- | ------ | ---- | -------- | 799| windowId | number | 是 | 窗口id。 | 800 801**返回值**: 802 803| 参数 | 说明 | 804| ---------------------------------------- | ------------------- | 805| Promise<[PointerStyle](#pointerstyle)> | Promise实例,异步返回鼠标样式类型。 | 806 807**示例**: 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 838使用同步方式获取鼠标样式类型。 839 840**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 841 842**参数**: 843 844| 参数名 | 类型 | 必填 | 说明 | 845| -------- | ------ | ---- | -------- | 846| windowId | number | 是 | 窗口id。 | 847 848**返回值**: 849 850| 参数 | 说明 | 851| ---------------------------------------- | ------------------- | 852| [PointerStyle](#pointerstyle) | 返回鼠标样式类型。 | 853 854**示例**: 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 869设置鼠标样式类型,使用AsyncCallback异步方式返回结果。 870 871**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 872 873**参数**: 874 875| 参数名 | 类型 | 必填 | 说明 | 876| ------------ | ------------------------------ | ---- | ----------------------------------- | 877| windowId | number | 是 | 窗口id。 | 878| pointerStyle | [PointerStyle](#pointerstyle) | 是 | 鼠标样式。 | 879| callback | AsyncCallback<void> | 是 | 回调函数。 | 880 881**示例**: 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 910设置鼠标样式类型,使用Promise异步方式返回结果。 911 912**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 913 914**参数**: 915 916| 参数名 | 类型 | 必填 | 说明 | 917| ------------------- | ------------------------------ | ---- | ---------------- | 918| windowId | number | 是 | 窗口id。 | 919| pointerStyle | [PointerStyle](#pointerstyle) | 是 | 鼠标样式。 | 920| Promise<void> | void | 是 | Promise对象。 | 921 922**示例**: 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 952使用同步方式设置鼠标样式类型。 953 954**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 955 956**参数**: 957 958| 参数名 | 类型 | 必填 | 说明 | 959| ------------------- | ------------------------------ | ---- | ---------------- | 960| windowId | number | 是 | 窗口id。 | 961| pointerStyle | [PointerStyle](#pointerstyle) | 是 | 鼠标样式。 | 962 963**示例**: 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 989鼠标样式类型。 990 991**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 992 993| 名称 | 值 | 说明 |图示 | 994| -------------------------------- | ---- | ------ |------ | 995| DEFAULT | 0 | 默认 || 996| EAST | 1 | 向东箭头 || 997| WEST | 2 | 向西箭头 || 998| SOUTH | 3 | 向南箭头 || 999| NORTH | 4 | 向北箭头 || 1000| WEST_EAST | 5 | 向西东箭头 || 1001| NORTH_SOUTH | 6 | 向北南箭头 || 1002| NORTH_EAST | 7 | 向东北箭头 || 1003| NORTH_WEST | 8 | 向西北箭头 || 1004| SOUTH_EAST | 9 | 向东南箭头 || 1005| SOUTH_WEST | 10 | 向西南箭头 || 1006| NORTH_EAST_SOUTH_WEST | 11 | 东北西南调整 || 1007| NORTH_WEST_SOUTH_EAST | 12 | 西北东南调整 || 1008| CROSS | 13 | 准确选择 || 1009| CURSOR_COPY | 14 | 拷贝 || 1010| CURSOR_FORBID | 15 | 不可用 || 1011| COLOR_SUCKER | 16 | 滴管 || 1012| HAND_GRABBING | 17 | 并拢的手 || 1013| HAND_OPEN | 18 | 张开的手 || 1014| HAND_POINTING | 19 | 手形指针 || 1015| HELP | 20 | 帮助选择 || 1016| MOVE | 21 | 移动 || 1017| RESIZE_LEFT_RIGHT | 22 | 内部左右调整 || 1018| RESIZE_UP_DOWN | 23 | 内部上下调整 || 1019| SCREENSHOT_CHOOSE | 24 | 截图十字准星 || 1020| SCREENSHOT_CURSOR | 25 | 截图 || 1021| TEXT_CURSOR | 26 | 文本选择 || 1022| ZOOM_IN | 27 | 放大 || 1023| ZOOM_OUT | 28 | 缩小 || 1024| MIDDLE_BTN_EAST | 29 | 向东滚动 || 1025| MIDDLE_BTN_WEST | 30 | 向西滚动 || 1026| MIDDLE_BTN_SOUTH | 31 | 向南滚动 |  | 1027| MIDDLE_BTN_NORTH | 32 | 向北滚动 || 1028| MIDDLE_BTN_NORTH_SOUTH | 33 | 向北南滚动 || 1029| MIDDLE_BTN_NORTH_EAST | 34 | 向东北滚动 || 1030| MIDDLE_BTN_NORTH_WEST | 35 | 向西北滚动 || 1031| MIDDLE_BTN_SOUTH_EAST | 36 | 向东南滚动 || 1032| MIDDLE_BTN_SOUTH_WEST | 37 | 向西南滚动 || 1033| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | 四向锥形移动 || 1034| HORIZONTAL_TEXT_CURSOR<sup>10+</sup> | 39 | 垂直文本选择 || 1035| CURSOR_CROSS<sup>10+</sup> | 40 | 十字光标 || 1036| CURSOR_CIRCLE<sup>10+</sup> | 41 | 圆形光标 || 1037| LOADING<sup>10+</sup> | 42 | 正在载入动画光标 || 1038| RUNNING<sup>10+</sup> | 43 | 后台运行中动画光标 || 1039 1040## pointer.setTouchpadScrollSwitch<sup>10+</sup> 1041 1042setTouchpadScrollSwitch(state: boolean, callback: AsyncCallback\<void>): void 1043 1044设置触控板滚轴开关,使用AsyncCallback异步方式返回结果。 1045 1046**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1047 1048**系统API**: 此接口为系统接口。 1049 1050**参数**: 1051 1052| 参数名 | 类型 | 必填 | 说明 | 1053| -------- | ------------------------- | ---- | ------------------------------------- | 1054| state | boolean | 是 | 滚轴开关开启的状态,true代表开启,false代表关闭,默认为开启 | 1055| callback | AsyncCallback\<void> | 是 | 回调函数。 | 1056 1057**示例**: 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 1077设置触控板滚轴开关,使用Promise异步方式返回结果。 1078 1079**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1080 1081**系统API**: 此接口为系统接口。 1082 1083**参数**: 1084 1085| 参数名 | 类型 | 必填 | 说明 | 1086| ----- | ------ | ---- | ----------------------------------- | 1087| state | boolean| 是 | 滚轴开关开启的状态,true代表开启,false代表关闭,默认为开启 | 1088 1089**返回值**: 1090 1091| 参数 | 说明 | 1092| ------------------- | ---------------- | 1093| Promise\<void> | Promise对象。 | 1094 1095**示例**: 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 1111获取触控板滚轴能力开启状态,使用AsyncCallback异步方式返回结果。 1112 1113**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1114 1115**系统API**: 此接口为系统接口。 1116 1117**参数**: 1118 1119| 参数名 | 类型 | 必填 | 说明 | 1120| -------- | --------------------------- | ---- | -------------- | 1121| callback | AsyncCallback\<boolean> | 是 | 回调函数,异步返回触控板滚轴能力开启状态。true代表开启,false代表关闭,默认为开启。 | 1122 1123**示例**: 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 1139获取触控板滚轴能力开启状态,使用Promise异步方式返回结果。 1140 1141**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1142 1143**系统API**: 此接口为系统接口。 1144 1145**返回值**: 1146 1147| 参数 | 说明 | 1148| --------------------- | ------------------- | 1149| Promise\<boolean> | Promise实例,异步返回触控板滚轴能力开启状态。true代表开启,false代表关闭,默认为开启。 | 1150 1151**示例**: 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 1167设置触控板滚轴的方向,使用AsyncCallback异步方式返回结果。 1168 1169**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1170 1171**系统API**: 此接口为系统接口。 1172 1173**参数**: 1174 1175| 参数名 | 类型 | 必填 | 说明 | 1176| -------- | ------------------------- | ---- | ------------------------------------- | 1177| state | boolean | 是 | state为触控板滚轴的方向。<br>true与手指滑动的方向一致,false与手指滑动的方向相反,<br>默认为true。 | 1178| callback | AsyncCallback\<void> | 是 | 回调函数。 | 1179 1180**示例**: 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 1200设置触控板滚轴的方向,使用Promise异步方式返回结果。 1201 1202**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1203 1204**系统API**: 此接口为系统接口。 1205 1206**参数**: 1207 1208| 参数名 | 类型 | 必填 | 说明 | 1209| ----- | ------ | ---- | ----------------------------------- | 1210| state | boolean| 是 | state为触控板滚轴的方向。<br>true与手指滑动的方向一致,false与手指滑动的方向相反。<br>默认为true| 1211 1212**返回值**: 1213 1214| 参数 | 说明 | 1215| ------------------- | ---------------- | 1216| Promise\<void> | Promise对象。 | 1217 1218**示例**: 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 1234获取触控板滚轴方向,使用AsyncCallback异步方式返回结果。 1235 1236**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1237 1238**系统API**: 此接口为系统接口。 1239 1240**参数**: 1241 1242| 参数名 | 类型 | 必填 | 说明 | 1243| -------- | --------------------------- | ---- | -------------- | 1244| callback | AsyncCallback\<boolean> | 是 | 回调函数,异步返回触控板滚轴方向。<br>true与手指滑动的方向一致,false与手指滑动的方向相反。<br>默认为true | 1245 1246**示例**: 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 1262获取触控板滚轴方向,使用Promise异步方式返回结果。 1263 1264**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1265 1266**系统API**: 此接口为系统接口。 1267 1268**返回值**: 1269 1270| 参数 | 说明 | 1271| --------------------- | ------------------- | 1272| Promise\<boolean> | Promise实例,异步返回触控板滚轴方向。 | 1273 1274**示例**: 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 1290设置触控板轻触功能开关,使用AsyncCallback异步方式返回结果。 1291 1292**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1293 1294**系统API**: 此接口为系统接口。 1295 1296**参数**: 1297 1298| 参数名 | 类型 | 必填 | 说明 | 1299| -------- | ------------------------- | ---- | ------------------------------------- | 1300| state | boolean | 是 |触控板轻触功能开关开启状态。 true代表轻触开启,false代表轻触关闭,默认开启。 | 1301| callback | AsyncCallback\<void> | 是 | 回调函数。 | 1302 1303**示例**: 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 1323设置触控板轻触功能开关,使用Promise异步方式返回结果。 1324 1325**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1326 1327**系统API**: 此接口为系统接口。 1328 1329**参数**: 1330 1331| 参数名 | 类型 | 必填 | 说明 | 1332| ----- | ------ | ---- | ----------------------------------- | 1333| state | boolean| 是 | 触控板轻触功能开关开启状态。 true代表轻触开启,false代表轻触关闭,默认开启。 | 1334 1335**返回值**: 1336 1337| 参数 | 说明 | 1338| ------------------- | ---------------- | 1339| Promise\<void> | Promise对象。 | 1340 1341**示例**: 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 1357获取触控板轻触能力开启状态,使用AsyncCallback异步方式返回结果。 1358 1359**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1360 1361**系统API**: 此接口为系统接口。 1362 1363**参数**: 1364 1365| 参数名 | 类型 | 必填 | 说明 | 1366| -------- | --------------------------- | ---- | -------------- | 1367| callback | AsyncCallback\<boolean> | 是 | 回调函数,异步返回触控板轻触功能开启状态, true代表开启,false代表关闭,默认开启。 | 1368 1369**示例**: 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 1385获取触控板轻触功能开启状态,使用Promise异步方式返回结果。 1386 1387**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1388 1389**系统API**: 此接口为系统接口。 1390 1391**返回值**: 1392 1393| 参数 | 说明 | 1394| --------------------- | ------------------- | 1395| Promise\<boolean> | Promise实例,异步返回触控板轻触功能开启状态,true代表开启,false代表关闭,默认开启。 | 1396 1397**示例**: 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 1413设置触控板光标移动速度,使用AsyncCallback异步方式返回结果。 1414 1415**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1416 1417**系统API**: 此接口为系统接口。 1418 1419**参数**: 1420 1421| 参数名 | 类型 | 必填 | 说明 | 1422| -------- | ------------------------- | ---- | ------------------------------------- | 1423| speed | number | 是 |speed代表光标移动速度。speed取值范围[1,11],默认5。 | 1424| callback | AsyncCallback\<void> | 是 | 回调函数。 | 1425 1426**示例**: 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 1446设置触控板光标移动速度,使用Promise异步方式返回结果。 1447 1448**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1449 1450**系统API**: 此接口为系统接口。 1451 1452**参数**: 1453 1454| 参数名 | 类型 | 必填 | 说明 | 1455| ----- | ------ | ---- | ----------------------------------- | 1456| speed| number | 是 | speed代表光标移动速度。speed取值范围[1,11],默认5。 | 1457 1458**返回值**: 1459 1460| 参数 | 说明 | 1461| ------------------- | ---------------- | 1462| Promise\<void> | Promise对象。 | 1463 1464**示例**: 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 1480获取触控板光标移动速度,使用AsyncCallback异步方式返回结果。 1481 1482**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1483 1484**系统API**: 此接口为系统接口。 1485 1486**参数**: 1487 1488| 参数名 | 类型 | 必填 | 说明 | 1489| -------- | --------------------------- | ---- | -------------- | 1490| callback | AsyncCallback\<number> | 是 | 回调函数,异步返回触控板光标移动速度。 | 1491 1492**示例**: 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 1508获取触控板光标移动速度,使用Promise异步方式返回结果。 1509 1510**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1511 1512**系统API**: 此接口为系统接口。 1513 1514**返回值**: 1515 1516| 参数 | 说明 | 1517| --------------------- | ------------------- | 1518| Promise\<number> | Promise实例,异步返回触控板光标移动速度。 | 1519 1520**示例**: 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 1536设置触控板双指捏合功能开关,使用AsyncCallback异步方式返回结果。 1537 1538**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1539 1540**系统API**: 此接口为系统接口。 1541 1542**参数**: 1543 1544| 参数名 | 类型 | 必填 | 说明 | 1545| -------- | ------------------------- | ---- | ------------------------------------- | 1546| state | boolean | 是 |触控板双指捏合功能开关开启状态。 true代表开启,false代表关闭,默认开启。 | 1547| callback | AsyncCallback\<void> | 是 | 回调函数。 | 1548 1549**示例**: 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 1569设置触控板双指捏合功能开关,使用Promise异步方式返回结果。 1570 1571**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1572 1573**系统API**: 此接口为系统接口。 1574 1575**参数**: 1576 1577| 参数名 | 类型 | 必填 | 说明 | 1578| ----- | ------ | ---- | ----------------------------------- | 1579| state | boolean| 是 | 触控板双指捏合功能开关开启状态。 true代表开启,false代表关闭,默认开启。 | 1580 1581**返回值**: 1582 1583| 参数 | 说明 | 1584| ------------------- | ---------------- | 1585| Promise\<void> | Promise对象。 | 1586 1587**示例**: 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 1603获取触控板双指捏合功能开启状态,使用AsyncCallback异步方式返回结果。 1604 1605**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1606 1607**系统API**: 此接口为系统接口。 1608 1609**参数**: 1610 1611| 参数名 | 类型 | 必填 | 说明 | 1612| -------- | --------------------------- | ---- | -------------- | 1613| callback | AsyncCallback\<boolean> | 是 | 回调函数,异步返回触控板双指捏合功能开启状态。true代表功能开启,false代表功能关闭,默认开启。 | 1614 1615**示例**: 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 1631获取触控板双指捏合功能开启状态,使用Promise异步方式返回结果。 1632 1633**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1634 1635**系统API**: 此接口为系统接口。 1636 1637**返回值**: 1638 1639| 参数 | 说明 | 1640| --------------------- | ------------------- | 1641| Promise\<boolean> | Promise实例,异步返回触控板双指捏合功能开启状态。true代表功能开启,false代表功能关闭,默认开启。 | 1642 1643**示例**: 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 1659设置触控板多指滑动功能开关,使用AsyncCallback异步方式返回结果。 1660 1661**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1662 1663**系统API**: 此接口为系统接口。 1664 1665**参数**: 1666 1667| 参数名 | 类型 | 必填 | 说明 | 1668| -------- | ------------------------- | ---- | ------------------------------------- | 1669| state | boolean | 是 |触控板多指滑动开关开启状态。 true代表多指滑动开启,false代表多指滑动关闭,默认开启。 | 1670| callback | AsyncCallback\<void> | 是 | 回调函数。 | 1671 1672**示例**: 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 1692设置触控板多指滑动功能开关,使用Promise异步方式返回结果。 1693 1694**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1695 1696**系统API**: 此接口为系统接口。 1697 1698**参数**: 1699 1700| 参数名 | 类型 | 必填 | 说明 | 1701| ----- | ------ | ---- | ----------------------------------- | 1702| state | boolean| 是 | 触控板多指滑动功能开关开启状态。 true代表多指滑动开启,false代表多指滑动关闭,默认开启。 | 1703 1704**返回值**: 1705 1706| 参数 | 说明 | 1707| ------------------- | ---------------- | 1708| Promise\<void> | Promise对象。 | 1709 1710**示例**: 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 1726获取触控板多指滑动功能开启状态,使用AsyncCallback异步方式返回结果。 1727 1728**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1729 1730**系统API**: 此接口为系统接口。 1731 1732**参数**: 1733 1734| 参数名 | 类型 | 必填 | 说明 | 1735| -------- | --------------------------- | ---- | -------------- | 1736| callback | AsyncCallback\<boolean> | 是 | 回调函数,异步返回触控板多指滑动功能开启状态。 true代表多指滑动开启,false代表多指滑动关闭,默认开启。 | 1737 1738**示例**: 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 1754获取触控板多指滑动功能开启状态,使用Promise异步方式返回结果。 1755 1756**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1757 1758**系统API**: 此接口为系统接口。 1759 1760**返回值**: 1761 1762| 参数 | 说明 | 1763| --------------------- | ------------------- | 1764| Promise\<boolean> | Promise实例,异步返回触控板多指滑动功能开启状态。 true代表多指滑动开启,false代表多指滑动关闭,默认开启。 | 1765 1766**示例**: 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 1780右键菜单触发方式。 1781 1782**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1783 1784| 名称 | 值 | 说明 | 1785| -------------------------------- | ---- | ------ | 1786| TOUCHPAD_RIGHT_BUTTON | 1 |触控板右键区域。 | 1787| TOUCHPAD_LEFT_BUTTON | 2 |触控板左键区域。 | 1788| TOUCHPAD_TWO_FINGER_TAP | 3 |双指轻击或按压触控板。| 1789 1790## pointer.setTouchpadRightClickType<sup>10+</sup> 1791 1792setTouchpadRightClickType(type: RightClickType, callback: AsyncCallback\<void>): void 1793 1794设置触控板右键菜单类型,使用AsyncCallback异步方式返回结果。 1795 1796**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1797 1798**系统API**: 此接口为系统接口。 1799 1800**参数**: 1801 1802| 参数名 | 类型 | 必填 | 说明 | 1803| -------- | ------------------------- | ---- | ------------------------------------- | 1804| type| [RightClickType](#rightclicktype10)| 是 |type代表触控板右键菜单类型。<br>- TOUCHPAD_RIGHT_BUTTON:触控板右键区域。<br>- TOUCHPAD_LEFT_BUTTON:触控板左键区域。<br>- TOUCHPAD_TWO_FINGER_TAP:双指轻击或按压触控板。<br>默认为TOUCHPAD_RIGHT_BUTTON 。 | 1805| callback | AsyncCallback\<void> | 是 | 回调函数。 | 1806 1807**示例**: 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 1827设置触控板右键菜单类型,使用Promise异步方式返回结果。 1828 1829**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1830 1831**系统API**: 此接口为系统接口。 1832 1833**参数**: 1834 1835| 参数名 | 类型 | 必填 | 说明 | 1836| ----- | ------ | ---- | ----------------------------------- | 1837| type| [RightClickType](#rightclicktype10)| 是 | type代表触控板右键菜单类型。<br>- TOUCHPAD_RIGHT_BUTTON:触控板右键区域。<br>- TOUCHPAD_LEFT_BUTTON:触控板左键区域。<br>- TOUCHPAD_TWO_FINGER_TAP:双指轻击或按压触控板。<br>默认为TOUCHPAD_RIGHT_BUTTON 。 | 1838 1839**返回值**: 1840 1841| 参数 | 说明 | 1842| ------------------- | ---------------- | 1843| Promise\<void> | Promise对象。 | 1844 1845**示例**: 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 1861获取触控板右键菜单类型,使用AsyncCallback异步方式返回结果。 1862 1863**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1864 1865**系统API**: 此接口为系统接口。 1866 1867**参数**: 1868 1869| 参数名 | 类型 | 必填 | 说明 | 1870| -------- | --------------------------- | ---- | -------------- | 1871| callback | AsyncCallback\<[RightClickType](#rightclicktype10)> | 是 | 回调函数,异步返回触控板右键菜单类型。 | 1872 1873**示例**: 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 1889获取触控板右键菜单类型,使用Promise异步方式返回结果。 1890 1891**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1892 1893**系统API**: 此接口为系统接口。 1894 1895**返回值**: 1896 1897| 参数 | 说明 | 1898| --------------------- | ------------------- | 1899| Promise\<[RightClickType](#rightclicktype10) > | Promise实例,异步返回触控板右键菜单类型。 | 1900 1901**示例**: 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 1917设置鼠标光标大小,使用AsyncCallback异步方式返回结果。 1918 1919**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1920 1921**系统API**: 此接口为系统接口。 1922 1923**参数**: 1924 1925| 参数名 | 类型 | 必填 | 说明 | 1926| -------- | ------------------------- | ---- | ------------------------------------- | 1927| size | number | 是 | 鼠标光标大小,范围为[1-7],默认为1。 | 1928| callback | AsyncCallback<void> | 是 | 回调函数,当设置成功时,err为undefined,否则为错误对象。 | 1929 1930**示例**: 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 1950设置鼠标光标大小,使用Promise异步方式返回结果。 1951 1952**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1953 1954**系统API**: 此接口为系统接口。 1955 1956**参数**: 1957 1958| 参数名 | 类型 | 必填 | 说明 | 1959| ----- | ------ | ---- | ----------------------------------- | 1960| size | number | 是 | 鼠标光标大小,范围为[1-7],默认为1。 | 1961 1962**返回值**: 1963 1964| 参数 | 说明 | 1965| ------------------- | ---------------- | 1966| Promise<void> | 无返回结果的Promise对象。 | 1967 1968**示例**: 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 1984设置鼠标光标大小,使用同步方式进行设置。 1985 1986**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 1987 1988**系统API**: 此接口为系统接口。 1989 1990**参数**: 1991 1992| 参数名 | 类型 | 必填 | 说明 | 1993| ----- | ------ | ---- | ----------------------------------- | 1994| size | number | 是 | 鼠标光标大小,范围为[1-7],默认为1。 | 1995 1996**示例**: 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 2011获取鼠标光标大小,使用AsyncCallback异步方式返回结果。 2012 2013**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 2014 2015**系统API**: 此接口为系统接口。 2016 2017**参数**: 2018 2019| 参数名 | 类型 | 必填 | 说明 | 2020| -------- | --------------------------- | ---- | -------------- | 2021| callback | AsyncCallback<number> | 是 | 回调函数,异步返回鼠标光标大小。 | 2022 2023**示例**: 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 2039获取当前鼠标光标大小,使用Promise异步方式返回结果。 2040 2041**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 2042 2043**系统API**: 此接口为系统接口。 2044 2045**返回值**: 2046 2047| 参数 | 说明 | 2048| --------------------- | ------------------- | 2049| Promise<number> | Promise对象,异步返回鼠标光标大小。 | 2050 2051**示例**: 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 2067获取鼠标光标大小,使用同步方式返回结果。 2068 2069**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 2070 2071**系统API**: 此接口为系统接口。 2072 2073**返回值**: 2074 2075| 参数 | 说明 | 2076| --------------------- | ------------------- | 2077| number | 鼠标光标大小。 | 2078 2079**示例**: 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 2094设置鼠标光标颜色,使用AsyncCallback异步方式返回结果。 2095 2096**说明** 2097> 2098> 设置和调试时,需连接外部设备,如鼠标、蓝牙等。 2099 2100**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 2101 2102**系统API**: 此接口为系统接口。 2103 2104**参数**: 2105 2106| 参数名 | 类型 | 必填 | 说明 | 2107| -------- | ------------------------- | ---- | ------------------------------------- | 2108| color | number | 是 | 鼠标光标颜色,默认为黑色:0x000000。 | 2109| callback | AsyncCallback<void> | 是 | 回调函数,当设置成功时,err为undefined,否则为错误对象。 | 2110 2111**示例**: 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 2131设置鼠标光标颜色,使用Promise异步方式返回结果。 2132 2133**说明** 2134> 2135> 设置和调试时,需连接外部设备,如鼠标、蓝牙等。 2136 2137**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 2138 2139**系统API**: 此接口为系统接口。 2140 2141**参数**: 2142 2143| 参数名 | 类型 | 必填 | 说明 | 2144| ----- | ------ | ---- | ----------------------------------- | 2145| color | number | 是 | 鼠标光标颜色,默认为黑色:0x000000。 | 2146 2147**返回值**: 2148 2149| 参数 | 说明 | 2150| ------------------- | ---------------- | 2151| Promise<void> | 无返回结果的Promise对象。 | 2152 2153**示例**: 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 2169设置鼠标光标颜色,使用同步方式进行设置。 2170 2171**说明** 2172> 2173> 设置和调试时,需连接外部设备,如鼠标、蓝牙等。 2174 2175**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 2176 2177**系统API**: 此接口为系统接口。 2178 2179**参数**: 2180 2181| 参数名 | 类型 | 必填 | 说明 | 2182| ----- | ------ | ---- | ----------------------------------- | 2183| color | number | 是 | 鼠标光标颜色,默认为黑色:0x000000。 | 2184 2185**示例**: 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 2200获取鼠标光标颜色,使用AsyncCallback异步方式返回结果。 2201 2202**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 2203 2204**系统API**: 此接口为系统接口。 2205 2206**参数**: 2207 2208| 参数名 | 类型 | 必填 | 说明 | 2209| -------- | --------------------------- | ---- | -------------- | 2210| callback | AsyncCallback<number> | 是 | 回调函数,异步返回鼠标光标颜色。 | 2211 2212**示例**: 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 2228获取当前鼠标光标颜色,使用Promise异步方式返回结果。 2229 2230**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 2231 2232**系统API**: 此接口为系统接口。 2233 2234**返回值**: 2235 2236| 参数 | 说明 | 2237| --------------------- | ------------------- | 2238| Promise<number> | Promise对象,异步返回鼠标光标颜色。 | 2239 2240**示例**: 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 2256获取鼠标光标颜色,使用同步方式返回结果。 2257 2258**系统能力**:SystemCapability.MultimodalInput.Input.Pointer 2259 2260**系统API**: 此接口为系统接口。 2261 2262**返回值**: 2263 2264| 参数 | 说明 | 2265| --------------------- | ------------------- | 2266| number | 鼠标光标颜色。 | 2267 2268**示例**: 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```