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 '@kit.InputKit';
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**Error codes**
31
32For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
33
34| ID | Error Message            |
35| ---- | --------------------- |
36| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
37
38**Example**
39
40```js
41try {
42  pointer.setPointerVisible(true, (error: Error) => {
43    if (error) {
44      console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
45      return;
46    }
47    console.log(`Set pointer visible success`);
48  });
49} catch (error) {
50  console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
51}
52```
53
54## pointer.setPointerVisible
55
56setPointerVisible(visible: boolean): Promise<void>
57
58Sets the visible status of the mouse pointer. This API uses a promise to return the result.
59
60**System capability**: SystemCapability.MultimodalInput.Input.Pointer
61
62**Parameters**
63
64| Name     | Type     | Mandatory  | Description                                      |
65| ------- | ------- | ---- | ---------------------------------------- |
66| 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.|
67
68**Return value**
69
70| Name                 | Description                 |
71| ------------------- | ------------------- |
72| Promise<void> | Promise used to return the result.|
73
74**Error codes**
75
76For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
77
78| ID | Error Message            |
79| ---- | --------------------- |
80| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
81
82**Example**
83
84```js
85try {
86  pointer.setPointerVisible(false).then(() => {
87    console.log(`Set pointer visible success`);
88  });
89} catch (error) {
90  console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
91}
92```
93
94## pointer.setPointerVisibleSync<sup>10+</sup>
95
96setPointerVisibleSync(visible: boolean): void
97
98Sets the visible status of the mouse pointer. This API returns the result synchronously.
99
100**System capability**: SystemCapability.MultimodalInput.Input.Pointer
101
102**Parameters**
103
104| Name     | Type     | Mandatory  | Description                                      |
105| ------- | ------- | ---- | ---------------------------------------- |
106| 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.|
107
108**Error codes**
109
110For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
111
112| ID | Error Message            |
113| ---- | --------------------- |
114| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
115
116**Example**
117
118```js
119try {
120  pointer.setPointerVisibleSync(false);
121  console.log(`Set pointer visible success`);
122} catch (error) {
123  console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
124}
125```
126
127## pointer.isPointerVisible
128
129isPointerVisible(callback: AsyncCallback&lt;boolean&gt;): void
130
131Checks the visible status of the mouse pointer. This API uses an asynchronous callback to return the result.
132
133**System capability**: SystemCapability.MultimodalInput.Input.Pointer
134
135**Parameters**
136
137| Name      | Type                          | Mandatory  | Description            |
138| -------- | ---------------------------- | ---- | -------------- |
139| callback | AsyncCallback&lt;boolean&gt; | Yes   | Callback used to return the result. The value **true** indicates that the mouse pointer is displayed, and the value **false** indicates the opposite.|
140
141**Error codes**
142
143For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
144
145| ID | Error Message            |
146| ---- | --------------------- |
147| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
148
149**Example**
150
151```js
152try {
153  pointer.isPointerVisible((error: Error, visible: boolean) => {
154    if (error) {
155      console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
156      return;
157    }
158    console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
159  });
160} catch (error) {
161  console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
162}
163```
164
165## pointer.isPointerVisible
166
167isPointerVisible(): Promise&lt;boolean&gt;
168
169Checks the visible status of the mouse pointer. This API uses a promise to return the result.
170
171**System capability**: SystemCapability.MultimodalInput.Input.Pointer
172
173**Return value**
174
175| Name                    | Description                 |
176| ---------------------- | ------------------- |
177| Promise&lt;boolean&gt; | Promise used to return the result.|
178
179**Example**
180
181```js
182try {
183  pointer.isPointerVisible().then((visible: boolean) => {
184    console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
185  });
186} catch (error) {
187  console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
188}
189```
190
191## pointer.isPointerVisibleSync<sup>10+</sup>
192
193isPointerVisibleSync(): boolean
194
195Obtains the visible status of the mouse pointer. This API returns the result synchronously.
196
197**System capability**: SystemCapability.MultimodalInput.Input.Pointer
198
199**Return value**
200
201| Name                    | Description                 |
202| ---------------------- | ------------------- |
203| boolean | Visible status of the mouse pointer. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.|
204
205**Example**
206
207```js
208try {
209  let visible: boolean = pointer.isPointerVisibleSync();
210  console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
211} catch (error) {
212  console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
213}
214```
215
216## pointer.getPointerStyle
217
218getPointerStyle(windowId: number, callback: AsyncCallback&lt;PointerStyle&gt;): void
219
220Obtains the mouse pointer style. This API uses an asynchronous callback to return the result.
221
222**System capability**: SystemCapability.MultimodalInput.Input.Pointer
223
224**Parameters**
225
226| Name      | Type                                      | Mandatory  | Description            |
227| -------- | ---------------------------------------- | ---- | -------------- |
228| windowId | number                                   | Yes   | Window ID.   |
229| callback | AsyncCallback&lt;[PointerStyle](#pointerstyle)&gt; | Yes   | Callback used to return the result.|
230
231**Error codes**
232
233For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
234
235| ID | Error Message            |
236| ---- | --------------------- |
237| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
238
239**Example**
240
241```js
242import { BusinessError } from '@kit.BasicServicesKit';
243import { window } from '@kit.ArkUI';
244
245let context = getContext(this);
246window.getLastWindow(context, (error: BusinessError, win: window.Window) => {
247  if (error.code) {
248    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
249    return;
250  }
251  let windowId = win.getWindowProperties().id;
252  if (windowId < 0) {
253    console.log(`Invalid windowId`);
254    return;
255  }
256  try {
257    pointer.getPointerStyle(windowId, (error: Error, style: pointer.PointerStyle) => {
258      console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
259    });
260  } catch (error) {
261    console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
262  }
263});
264```
265
266## pointer.getPointerStyle
267
268getPointerStyle(windowId: number): Promise&lt;PointerStyle&gt;
269
270Obtains the mouse pointer style. This API uses a promise to return the result.
271
272**System capability**: SystemCapability.MultimodalInput.Input.Pointer
273
274**Parameters**
275
276| Name    | Type  | Mandatory| Description    |
277| -------- | ------ | ---- | -------- |
278| windowId | number | Yes  | Window ID.|
279
280**Return value**
281
282| Name                                      | Description                 |
283| ---------------------------------------- | ------------------- |
284| Promise&lt;[PointerStyle](#pointerstyle)&gt; | Promise used to return the result.|
285
286**Error codes**
287
288For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
289
290| ID | Error Message            |
291| ---- | --------------------- |
292| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
293
294**Example**
295
296```js
297import { BusinessError } from '@kit.BasicServicesKit';
298import { window } from '@kit.ArkUI';
299
300let context = getContext(this);
301window.getLastWindow(context, (error: BusinessError, win: window.Window) => {
302  if (error.code) {
303    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
304    return;
305  }
306  let windowId = win.getWindowProperties().id;
307  if (windowId < 0) {
308    console.log(`Invalid windowId`);
309    return;
310  }
311  try {
312    pointer.getPointerStyle(windowId).then((style: pointer.PointerStyle) => {
313      console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
314    });
315  } catch (error) {
316    console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
317  }
318});
319```
320
321## pointer.getPointerStyleSync<sup>10+</sup>
322
323getPointerStyleSync(windowId: number): PointerStyle
324
325Obtains the mouse pointer style. This API returns the result synchronously.
326
327**System capability**: SystemCapability.MultimodalInput.Input.Pointer
328
329**Parameters**
330
331| Name    | Type  | Mandatory| Description    |
332| -------- | ------ | ---- | -------- |
333| windowId | number | Yes  | Window ID.<br>The default value is **-1**, indicating the global mouse pointer style.|
334
335**Return value**
336
337| Name                                      | Description                 |
338| ---------------------------------------- | ------------------- |
339| [PointerStyle](#pointerstyle) | Mouse pointer style.|
340
341**Error codes**
342
343For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
344
345| ID | Error Message            |
346| ---- | --------------------- |
347| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
348
349**Example**
350
351```js
352import { pointer } from '@kit.InputKit';
353
354let windowId = -1;
355try {
356  let style: pointer.PointerStyle = pointer.getPointerStyleSync(windowId);
357  console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
358} catch (error) {
359  console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
360}
361```
362
363## pointer.setPointerStyle
364
365setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback&lt;void&gt;): void
366
367Sets the mouse pointer style. This API uses an asynchronous callback to return the result.
368
369**System capability**: SystemCapability.MultimodalInput.Input.Pointer
370
371**Parameters**
372
373| Name          | Type                            | Mandatory  | Description                                 |
374| ------------ | ------------------------------ | ---- | ----------------------------------- |
375| windowId     | number                         | Yes   | Window ID.                         |
376| pointerStyle | [PointerStyle](#pointerstyle) | Yes   | Pointer style.                            |
377| callback     | AsyncCallback&lt;void&gt;      | Yes   | Callback used to return the result.|
378
379**Error codes**
380
381For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
382
383| ID | Error Message            |
384| ---- | --------------------- |
385| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
386
387**Example**
388
389```js
390import { BusinessError } from '@kit.BasicServicesKit';
391import { window } from '@kit.ArkUI';
392
393window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => {
394  if (error.code) {
395    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
396    return;
397  }
398  let windowId = win.getWindowProperties().id;
399  if (windowId < 0) {
400    console.log(`Invalid windowId`);
401    return;
402  }
403  try {
404    pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => {
405      console.log(`Set pointer style success`);
406    });
407  } catch (error) {
408    console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
409  }
410});
411```
412## pointer.setPointerStyle
413
414setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise&lt;void&gt;
415
416Sets the mouse pointer style. This API uses a promise to return the result.
417
418**System capability**: SystemCapability.MultimodalInput.Input.Pointer
419
420**Parameters**
421
422| Name                 | Type                            | Mandatory  | Description              |
423| ------------------- | ------------------------------ | ---- | ---------------- |
424| windowId            | number                         | Yes   | Window ID.      |
425| pointerStyle        | [PointerStyle](#pointerstyle) | Yes   | Pointer style.         |
426
427**Return value**
428
429| Name                 | Description                 |
430| ------------------- | ------------------- |
431| Promise&lt;void&gt; | Promise used to return the result.|
432
433**Error codes**
434
435For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
436
437| ID | Error Message            |
438| ---- | --------------------- |
439| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
440
441**Example**
442
443```js
444import { BusinessError } from '@kit.BasicServicesKit';
445import { window } from '@kit.ArkUI';
446
447window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => {
448  if (error.code) {
449    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
450    return;
451  }
452  let windowId = win.getWindowProperties().id;
453  if (windowId < 0) {
454    console.log(`Invalid windowId`);
455    return;
456  }
457  try {
458    pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => {
459      console.log(`Set pointer style success`);
460    });
461  } catch (error) {
462    console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
463  }
464});
465```
466
467## pointer.setPointerStyleSync<sup>10+</sup>
468
469setPointerStyleSync(windowId: number, pointerStyle: PointerStyle): void
470
471Sets the mouse pointer style. This API returns the result synchronously.
472
473**System capability**: SystemCapability.MultimodalInput.Input.Pointer
474
475**Parameters**
476
477| Name                 | Type                            | Mandatory  | Description              |
478| ------------------- | ------------------------------ | ---- | ---------------- |
479| windowId            | number                         | Yes   | Window ID.      |
480| pointerStyle        | [PointerStyle](#pointerstyle) | Yes   | Pointer style.         |
481
482**Error codes**
483
484For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
485
486| ID | Error Message            |
487| ---- | --------------------- |
488| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
489
490**Example**
491```js
492import { BusinessError } from '@kit.BasicServicesKit';
493import { window } from '@kit.ArkUI';
494
495window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => {
496  if (error.code) {
497    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
498    return;
499  }
500  let windowId = win.getWindowProperties().id;
501  if (windowId < 0) {
502    console.log(`Invalid windowId`);
503    return;
504  }
505  try {
506    pointer.setPointerStyleSync(windowId, pointer.PointerStyle.CROSS);
507    console.log(`Set pointer style success`);
508  } catch (error) {
509    console.log(`getPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
510  }
511});
512```
513
514## PrimaryButton<sup>10+</sup>
515
516Type of the primary mouse button.
517
518**System capability**: SystemCapability.MultimodalInput.Input.Pointer
519
520| Name                              | Value   | Description    |
521| -------------------------------- | ---- | ------ |
522| LEFT                          | 0    | Left mouse button.    |
523| RIGHT                             | 1    | Right mouse button.  |
524
525## RightClickType<sup>10+</sup>
526
527Enumerates shortcut menu triggering modes.
528
529**System capability**: SystemCapability.MultimodalInput.Input.Pointer
530
531| Name                              | Value   | Description    |
532| -------------------------------- | ---- | ------ |
533| TOUCHPAD_RIGHT_BUTTON            | 1    |Tapping the right-button area of the touchpad.|
534| TOUCHPAD_LEFT_BUTTON            | 2    |Tapping the left-button area of the touchpad.|
535| TOUCHPAD_TWO_FINGER_TAP         | 3    |Tapping or pressing the touchpad with two fingers.|
536
537## PointerStyle
538
539Enumerates mouse pointer styles.
540
541**System capability**: SystemCapability.MultimodalInput.Input.Pointer
542
543| Name                              | Value   | Description    |Legend|
544| -------------------------------- | ---- | ------ |------ |
545| DEFAULT                          | 0    | Default     |![Default.png](./figures/Default.png)|
546| EAST                             | 1    | East arrow  |![East.png](./figures/East.png)|
547| WEST                             | 2    | West arrow  |![West.png](./figures/West.png)|
548| SOUTH                            | 3    | South arrow  |![South.png](./figures/South.png)|
549| NORTH                            | 4    | North arrow  |![North.png](./figures/North.png)|
550| WEST_EAST                        | 5    | West-east arrow |![West_East.png](./figures/West_East.png)|
551| NORTH_SOUTH                      | 6    | North-south arrow |![North_South.png](./figures/North_South.png)|
552| NORTH_EAST                       | 7    | North-east arrow |![North_East.png](./figures/North_East.png)|
553| NORTH_WEST                       | 8    | North-west arrow |![North_West.png](./figures/North_West.png)|
554| SOUTH_EAST                       | 9    | South-east arrow |![South_East.png](./figures/South_East.png)|
555| SOUTH_WEST                       | 10   | South-west arrow |![South_West.png](./figures/South_West.png)|
556| NORTH_EAST_SOUTH_WEST            | 11   | North-east and south-west adjustment|![North_East_South_West.png](./figures/North_East_South_West.png)|
557| NORTH_WEST_SOUTH_EAST            | 12   | North-west and south-east adjustment|![North_West_South_East.png](./figures/North_West_South_East.png)|
558| CROSS                            | 13   | Cross (accurate selection)  |![Cross.png](./figures/Cross.png)|
559| CURSOR_COPY                      | 14   | Copy    |![Copy.png](./figures/Copy.png)|
560| CURSOR_FORBID                    | 15   | Forbid   |![Forbid.png](./figures/Forbid.png)|
561| COLOR_SUCKER                     | 16   | Sucker    |![Colorsucker.png](./figures/Colorsucker.png)|
562| HAND_GRABBING                    | 17   | Grabbing hand  |![Hand_Grabbing.png](./figures/Hand_Grabbing.png)|
563| HAND_OPEN                        | 18   | Opening hand  |![Hand_Open.png](./figures/Hand_Open.png)|
564| HAND_POINTING                    | 19   | Hand-shaped pointer  |![Hand_Poniting.png](./figures/Hand_Pointing.png)|
565| HELP                             | 20   | Help   |![Help.png](./figures/Help.png)|
566| MOVE                             | 21   | Move    |![Move.png](./figures/Move.png)|
567| RESIZE_LEFT_RIGHT                | 22   | Left and right resizing|![Resize_Left_Right.png](./figures/Resize_Left_Right.png)|
568| RESIZE_UP_DOWN                   | 23   | Up and down resizing|![Resize_Up_Down.png](./figures/Resize_Up_Down.png)|
569| SCREENSHOT_CHOOSE                | 24   | Screenshot crosshair|![Screenshot_Cross.png](./figures/Screenshot_Cross.png)|
570| SCREENSHOT_CURSOR                | 25   | Screenshot    |![Screenshot_Cursor.png](./figures/Screenshot_Cursor.png)|
571| TEXT_CURSOR                      | 26   | Text selection  |![Text_Cursor.png](./figures/Text_Cursor.png)|
572| ZOOM_IN                          | 27   | Zoom in    |![Zoom_In.png](./figures/Zoom_In.png)|
573| ZOOM_OUT                         | 28   | Zoom out    |![Zoom_Out.png](./figures/Zoom_Out.png)|
574| MIDDLE_BTN_EAST                  | 29   | Scrolling east  |![MID_Btn_East.png](./figures/MID_Btn_East.png)|
575| MIDDLE_BTN_WEST                  | 30   | Scrolling west  |![MID_Btn_West.png](./figures/MID_Btn_West.png)|
576| MIDDLE_BTN_SOUTH                 | 31   | Scrolling south  | ![MID_Btn_South.png](./figures/MID_Btn_South.png)            |
577| MIDDLE_BTN_NORTH                 | 32   | Scrolling north  |![MID_Btn_North.png](./figures/MID_Btn_North.png)|
578| MIDDLE_BTN_NORTH_SOUTH           | 33   | Scrolling north-south |![MID_Btn_North_South.png](./figures/MID_Btn_North_South.png)|
579| MIDDLE_BTN_NORTH_EAST            | 34   | Scrolling north-east |![MID_Btn_North_East.png](./figures/MID_Btn_North_East.png)|
580| MIDDLE_BTN_NORTH_WEST            | 35   | Scrolling north-west |![MID_Btn_North_West.png](./figures/MID_Btn_North_West.png)|
581| MIDDLE_BTN_SOUTH_EAST            | 36   | Scrolling south-east |![MID_Btn_South_East.png](./figures/MID_Btn_South_East.png)|
582| MIDDLE_BTN_SOUTH_WEST            | 37   | Scrolling south-west |![MID_Btn_South_West.png](./figures/MID_Btn_South_West.png)|
583| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38   | Moving as a cone in four directions|![MID_Btn_North_South_West_East.png](./figures/MID_Btn_North_South_West_East.png)|
584| HORIZONTAL_TEXT_CURSOR<sup>10+</sup> | 39 | Horizontal text selection|![Horizontal_Text_Cursor.png](./figures/Horizontal_Text_Cursor.png)|
585| CURSOR_CROSS<sup>10+</sup> | 40 | Cross|![Cursor_Cross.png](./figures/Cursor_Cross.png)|
586| CURSOR_CIRCLE<sup>10+</sup> | 41 | Circle|![Cursor_Circle.png](./figures/Cursor_Circle.png)|
587| LOADING<sup>10+</sup> | 42 | Animation loading|![Loading.png](./figures/Loading.png)<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
588| RUNNING<sup>10+</sup> | 43 | Animation running in the background|![Running.png](./figures/Running.png)<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
589
590## pointer.setCustomCursor<sup>11+</sup>
591
592setCustomCursor(windowId: number, pixelMap: image.PixelMap, focusX?: number, focusY?: number): Promise&lt;void&gt;
593
594Sets a custom cursor. This API uses a promise to return the result.
595
596**System capability**: SystemCapability.MultimodalInput.Input.Pointer
597
598**Parameters**
599
600| Name   | Type    | Mandatory  | Description                                 |
601| ----- | ------ | ---- | ----------------------------------- |
602| windowId  | number  | Yes   | Window ID.                         |
603| pixelMap  | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes   | Pixel map resource.|
604| focusX  | number | No   | Focus x of the custom cursor. The value is greater than or equal to **0**. The default value is **0**.|
605| focusY  | number | No   | Focus y of the custom cursor. The value is greater than or equal to **0**. The default value is **0**.|
606
607**Return value**
608
609| Name                 | Description              |
610| ------------------- | ---------------- |
611| Promise&lt;void&gt; | Promise that returns no value.|
612
613**Error codes**
614
615For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
616
617| ID | Error Message            |
618| ---- | --------------------- |
619| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
620
621**Example**
622
623```js
624import { image } from '@kit.ImageKit';
625import { BusinessError } from '@kit.BasicServicesKit';
626import { window } from '@kit.ArkUI';
627getContext().resourceManager.getMediaContent($r("app.media.app_icon")).then((svgFileData) => {
628  const svgBuffer: ArrayBuffer = svgFileData.buffer.slice(0);
629  let svgImagesource: image.ImageSource = image.createImageSource(svgBuffer);
630  let svgDecodingOptions: image.DecodingOptions = {desiredSize: { width: 50, height:50 }};
631  svgImagesource.createPixelMap(svgDecodingOptions).then((pixelMap) => {
632    window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => {
633      let windowId = win.getWindowProperties().id;
634        try {
635          pointer.setCustomCursor(windowId, pixelMap).then(() => {
636            console.log(`setCustomCursor success`);
637          });
638        } catch (error) {
639          console.log(`setCustomCursor failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
640        }
641      });
642  });
643});
644```
645
646## pointer.setCustomCursorSync<sup>11+</sup>
647
648setCustomCursorSync(windowId: number, pixelMap: image.PixelMap, focusX?: number, focusY?: number): void
649
650Sets a custom cursor. This API returns the result synchronously.
651
652**System capability**: SystemCapability.MultimodalInput.Input.Pointer
653
654**Parameters**
655
656| Name   | Type    | Mandatory  | Description                                 |
657| ----- | ------ | ---- | ----------------------------------- |
658| windowId  | number  | Yes   | Window ID.                         |
659| pixelMap  | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes   | Pixel map resource.|
660| focusX  | number | No   | Focus x of the custom cursor. The value is greater than or equal to **0**. The default value is **0**.|
661| focusY  | number | No   | Focus y of the custom cursor. The value is greater than or equal to **0**. The default value is **0**.|
662
663**Error codes**
664
665For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
666
667| ID | Error Message            |
668| ---- | --------------------- |
669| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
670
671**Example**
672
673```js
674import { image } from '@kit.ImageKit';
675import { BusinessError } from '@kit.BasicServicesKit';
676import { window } from '@kit.ArkUI';
677const svgFileData = getContext().resourceManager.getMediaContent($r("app.media.app_icon")).then((svgFileData) => {
678  const svgBuffer: ArrayBuffer = svgFileData.buffer.slice(0);
679  let svgImagesource: image.ImageSource = image.createImageSource(svgBuffer);
680  let svgDecodingOptions: image.DecodingOptions = {desiredSize: { width: 50, height:50 }};
681  svgImagesource.createPixelMap(svgDecodingOptions).then((pixelMap) => {
682    window.getLastWindow(getContext(), (error: BusinessError, win: window.Window) => {
683      let windowId = win.getWindowProperties().id;
684        try {
685          pointer.setCustomCursorSync(windowId, pixelMap, 25, 25);
686          console.log(`setCustomCursorSync success`);
687        } catch (error) {
688          console.log(`setCustomCursorSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
689        }
690    });
691  });
692});
693```
694