harmony 鸿蒙@ohos.multimodalInput.pointer (鼠标指针)

  • 2025-06-16
  • 浏览 (2)

@ohos.multimodalInput.pointer (鼠标指针)

本模块提供鼠标指针管理能力,包括查询、设置鼠标指针属性。

说明

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

导入模块

import { pointer } from '@kit.InputKit';

pointer.setPointerVisible

setPointerVisible(visible: boolean, callback: AsyncCallback<void>): void

设置鼠标指针显示或者隐藏,使用Callback异步回调。

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

参数

参数名 类型 必填 说明
visible boolean 鼠标指针是否显示。true表示显示,false表示不显示。
callback AsyncCallback<void> 回调函数。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.
801 Capability not supported.

示例

try {
  pointer.setPointerVisible(true, (error: Error) => {
    if (error) {
      console.error(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
      return;
    }
    console.log(`Set pointer visible success`);
  });
} catch (error) {
  console.error(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.setPointerVisible

setPointerVisible(visible: boolean): Promise<void>

设置鼠标指针显示或者隐藏,使用Promise异步回调。

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

参数

参数名 类型 必填 说明
visible boolean 鼠标指针是否显示。true表示显示,false表示不显示。

返回值

类型 说明
Promise<void> 无返回结果的Promise对象。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.
801 Capability not supported.

示例

try {
  pointer.setPointerVisible(false).then(() => {
    console.log(`Set pointer visible success`);
  });
} catch (error) {
  console.error(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.setPointerVisibleSync10+

setPointerVisibleSync(visible: boolean): void

设置鼠标指针的显示或隐藏,使用同步方式。

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

参数

参数名 类型 必填 说明
visible boolean 鼠标指针是否显示。true表示显示,false表示不显示。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

try {
  pointer.setPointerVisibleSync(false);
  console.log(`Set pointer visible success`);
} catch (error) {
  console.error(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.isPointerVisible

isPointerVisible(callback: AsyncCallback<boolean>): void

获取鼠标指针显示状态,使用callback异步回调。

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

参数

参数名 类型 必填 说明
callback AsyncCallback<boolean> 回调函数,返回鼠标指针状态,true为显示,false为隐藏。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

try {
  pointer.isPointerVisible((error: Error, visible: boolean) => {
    if (error) {
      console.error(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
      return;
    }
    console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
  });
} catch (error) {
  console.error(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.isPointerVisible

isPointerVisible(): Promise<boolean>

获取鼠标指针显示状态,使用Promise异步回调。

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

返回值

类型 说明
Promise<boolean> Promise对象,返回鼠标指针状态查询结果。true代表显示状态,false代表隐藏状态。

示例

try {
  pointer.isPointerVisible().then((visible: boolean) => {
    console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
  });
} catch (error) {
  console.error(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.isPointerVisibleSync10+

isPointerVisibleSync(): boolean

使用同步方式获取鼠标指针显示或者隐藏。

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

返回值

类型 说明
boolean 返回鼠标指针显示或隐藏状态。true代表显示状态,false代表隐藏状态。

示例

try {
  let visible: boolean = pointer.isPointerVisibleSync();
  console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
} catch (error) {
  console.error(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getPointerStyle

getPointerStyle(windowId: number, callback: AsyncCallback<PointerStyle>): void

获取鼠标样式类型,使用Callback异步回调。

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

参数

参数名 类型 必填 说明
windowId number 窗口id。取值范围为大于等于-1的整数,取值为-1时表示全局窗口。
callback AsyncCallback<PointerStyle> 回调函数,返回鼠标样式类型。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';

window.getLastWindow(this.getUIContext().getHostContext(), (error: BusinessError, win: window.Window) => {
  if (error.code) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
    return;
  }
  let windowId = win.getWindowProperties().id;
  if (windowId < 0) {
    console.log(`Invalid windowId`);
    return;
  }
  try {
    pointer.getPointerStyle(windowId, (error: Error, style: pointer.PointerStyle) => {
      console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
    });
  } catch (error) {
    console.error(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

pointer.getPointerStyle

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

获取鼠标样式类型,使用Promise异步回调。

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

参数

参数名 类型 必填 说明
windowId number 窗口id。

返回值

类型 说明
Promise&lt;PointerStyle&gt; Promise实例,返回鼠标样式类型。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';

window.getLastWindow(this.getUIContext().getHostContext(), (error: BusinessError, win: window.Window) => {
  if (error.code) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
    return;
  }
  let windowId = win.getWindowProperties().id;
  if (windowId < 0) {
    console.log(`Invalid windowId`);
    return;
  }
  try {
    pointer.getPointerStyle(windowId).then((style: pointer.PointerStyle) => {
      console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
    });
  } catch (error) {
    console.error(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

pointer.getPointerStyleSync10+

getPointerStyleSync(windowId: number): PointerStyle

查询鼠标样式类型,如向东箭头、向西箭头、向南箭头、向北箭头等。

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

参数

参数名 类型 必填 说明
windowId number 窗口id。
默认值为-1,表示获取全局的鼠标样式。

返回值

类型 说明
PointerStyle 返回鼠标样式类型。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

import { pointer } from '@kit.InputKit';

let windowId = -1;
try {
  let style: pointer.PointerStyle = pointer.getPointerStyleSync(windowId);
  console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
} catch (error) {
  console.error(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.setPointerStyle

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

设置鼠标样式类型,使用Callback异步回调。

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

参数

参数名 类型 必填 说明
windowId number 窗口id。
pointerStyle PointerStyle 鼠标样式。
callback AsyncCallback&lt;void&gt; 回调函数。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';

window.getLastWindow(this.getUIContext().getHostContext(), (error: BusinessError, win: window.Window) => {
  if (error.code) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
    return;
  }
  let windowId = win.getWindowProperties().id;
  if (windowId < 0) {
    console.log(`Invalid windowId`);
    return;
  }
  try {
    pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => {
      console.log(`Set pointer style success`);
    });
  } catch (error) {
    console.error(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

pointer.setPointerStyle

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

设置鼠标样式类型,使用Promise异步回调。

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

参数

参数名 类型 必填 说明
windowId number 窗口id。
pointerStyle PointerStyle 鼠标样式。

返回值

类型 说明
Promise&lt;void&gt; 无返回结果的Promise对象。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';

window.getLastWindow(this.getUIContext().getHostContext(), (error: BusinessError, win: window.Window) => {
  if (error.code) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
    return;
  }
  let windowId = win.getWindowProperties().id;
  if (windowId < 0) {
    console.log(`Invalid windowId`);
    return;
  }
  try {
    pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => {
      console.log(`Set pointer style success`);
    });
  } catch (error) {
    console.error(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

pointer.setPointerStyleSync10+

setPointerStyleSync(windowId: number, pointerStyle: PointerStyle): void

设置鼠标样式类型,使用同步方式返回结果。

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

参数

参数名 类型 必填 说明
windowId number 窗口id。
pointerStyle PointerStyle 鼠标样式。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';

window.getLastWindow(this.getUIContext().getHostContext(), (error: BusinessError, win: window.Window) => {
  if (error.code) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
    return;
  }
  let windowId = win.getWindowProperties().id;
  if (windowId < 0) {
    console.log(`Invalid windowId`);
    return;
  }
  try {
    pointer.setPointerStyleSync(windowId, pointer.PointerStyle.CROSS);
    console.log(`Set pointer style success`);
  } catch (error) {
    console.error(`getPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

PrimaryButton10+

鼠标主键类型。

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

名称 说明
LEFT 0 鼠标左键。
RIGHT 1 鼠标右键。

RightClickType10+

右键菜单的触发方式。

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

名称 说明
TOUCHPAD_RIGHT_BUTTON 1 按压触控板右键区域。
TOUCHPAD_LEFT_BUTTON 2 按压触控板左键区域。
TOUCHPAD_TWO_FINGER_TAP 3 双指轻击或双指按压触控板。
TOUCHPAD_TWO_FINGER_TAP_OR_RIGHT_BUTTON20+ 4 双指轻击或双指按压触控板、或按压触控板右键区域。
TOUCHPAD_TWO_FINGER_TAP_OR_LEFT_BUTTON20+ 5 双指轻击或双指按压触控板、或按压触控板左键区域。

PointerStyle

鼠标样式类型。

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

名称 说明 图示
DEFAULT 0 默认 Default.png
EAST 1 向东箭头 East.png
WEST 2 向西箭头 West.png
SOUTH 3 向南箭头 South.png
NORTH 4 向北箭头 North.png
WEST_EAST 5 向西东箭头 West_East.png
NORTH_SOUTH 6 向北南箭头 North_South.png
NORTH_EAST 7 向东北箭头 North_East.png
NORTH_WEST 8 向西北箭头 North_West.png
SOUTH_EAST 9 向东南箭头 South_East.png
SOUTH_WEST 10 向西南箭头 South_West.png
NORTH_EAST_SOUTH_WEST 11 东北西南调整 North_East_South_West.png
NORTH_WEST_SOUTH_EAST 12 西北东南调整 North_West_South_East.png
CROSS 13 准确选择 Cross.png
CURSOR_COPY 14 拷贝 Copy.png
CURSOR_FORBID 15 不可用 Forbid.png
COLOR_SUCKER 16 滴管 Colorsucker.png
HAND_GRABBING 17 并拢的手 Hand_Grabbing.png
HAND_OPEN 18 张开的手 Hand_Open.png
HAND_POINTING 19 手形指针 Hand_Poniting.png
HELP 20 帮助选择 Help.png
MOVE 21 移动 Move.png
RESIZE_LEFT_RIGHT 22 内部左右调整 Resize_Left_Right.png
RESIZE_UP_DOWN 23 内部上下调整 Resize_Up_Down.png
SCREENSHOT_CHOOSE 24 截图十字准星 Screenshot_Cross.png
SCREENSHOT_CURSOR 25 截图 Screenshot_Cursor.png
TEXT_CURSOR 26 文本选择 Text_Cursor.png
ZOOM_IN 27 放大 Zoom_In.png
ZOOM_OUT 28 缩小 Zoom_Out.png
MIDDLE_BTN_EAST 29 向东滚动 MID_Btn_East.png
MIDDLE_BTN_WEST 30 向西滚动 MID_Btn_West.png
MIDDLE_BTN_SOUTH 31 向南滚动 MID_Btn_South.png
MIDDLE_BTN_NORTH 32 向北滚动 MID_Btn_North.png
MIDDLE_BTN_NORTH_SOUTH 33 向南北滚动 MID_Btn_North_South.png
MIDDLE_BTN_NORTH_EAST 34 向东北滚动 MID_Btn_North_East.png
MIDDLE_BTN_NORTH_WEST 35 向西北滚动 MID_Btn_North_West.png
MIDDLE_BTN_SOUTH_EAST 36 向东南滚动 MID_Btn_South_East.png
MIDDLE_BTN_SOUTH_WEST 37 向西南滚动 MID_Btn_South_West.png
MIDDLE_BTN_NORTH_SOUTH_WEST_EAST 38 四向锥形移动 MID_Btn_North_South_West_East.png
HORIZONTAL_TEXT_CURSOR10+ 39 垂直文本选择 Horizontal_Text_Cursor.png
CURSOR_CROSS10+ 40 十字光标 Cursor_Cross.png
CURSOR_CIRCLE10+ 41 圆形光标 Cursor_Circle.png
LOADING10+ 42 正在载入动画光标 Loading.png
原子化服务API: 从API version 12开始,该接口支持在原子化服务中使用。
RUNNING10+ 43 后台运行中动画光标 Running.png
原子化服务API: 从API version 12开始,该接口支持在原子化服务中使用。
MIDDLE_BTN_EAST_WEST18+ 44 向东西滚动 MID_Btn_East_West.png

pointer.setCustomCursor11+

setCustomCursor(windowId: number, pixelMap: image.PixelMap, focusX?: number, focusY?: number): Promise&lt;void&gt;

设置自定义光标样式,使用Promise异步回调。

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

参数

参数名 类型 必填 说明
windowId number 窗口id。
pixelMap image.PixelMap 自定义光标资源。
focusX number 自定义光标焦点x,取值范围:大于等于0,默认为0。
focusY number 自定义光标焦点y,取值范围:大于等于0,默认为0。

返回值

类型 说明
Promise&lt;void&gt; 无返回结果的Promise对象。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

import { image } from '@kit.ImageKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';

// app_icon为示例资源,请开发者根据实际需求配置资源文件。
this.getUIContext()?.getHostContext()?.resourceManager.getMediaContent($r("app.media.app_icon")).then((svgFileData) => {
  const svgBuffer: ArrayBuffer = svgFileData.buffer.slice(0);
  let svgImagesource: image.ImageSource = image.createImageSource(svgBuffer);
  let svgDecodingOptions: image.DecodingOptions = {desiredSize: { width: 50, height:50 }};
  svgImagesource.createPixelMap(svgDecodingOptions).then((pixelMap) => {
    window.getLastWindow(this.getUIContext().getHostContext(), (error: BusinessError, win: window.Window) => {
      let windowId = win.getWindowProperties().id;
        try {
          pointer.setCustomCursor(windowId, pixelMap).then(() => {
            console.log(`setCustomCursor success`);
          });
        } catch (error) {
          console.error(`setCustomCursor failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
        }
      });
  });
});

CustomCursor15+

自定义光标资源。

系统能力:SystemCapability.MultimodalInput.Input.Pointer |名称 |类型 |只读 |可选 |说明 | |——–|——-|——–|——–|——-| |pixelMap|image.PixelMap|否 |否 |自定义光标。最小限制为资源图本身的最小限制。最大限制为256 x 256px。| |focusX|number|否 |是 |自定义光标焦点的水平坐标。该坐标受自定义光标大小的限制。最小值为0,最大值为资源图的宽度最大值,该参数缺省时默认为0。| |focusY|number|否 |是 |自定义光标焦点的垂直坐标。该坐标受自定义光标大小的限制。最小值为0,最大值为资源图的高度最大值,该参数缺省时默认为0。|

CursorConfig15+

自定义光标配置。

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

名称 类型 只读 可选 说明
followSystem boolean 是否根据系统设置调整光标大小。false表示使用自定义光标样式大小,true表示根据系统设置调整光标大小,可调整范围为:[光标资源图大小,256×256]。

pointer.setCustomCursor15+

setCustomCursor(windowId: number, cursor: CustomCursor, config: CursorConfig): Promise&lt;void&gt;

设置自定义光标样式,使用Promise异步回调。 应用窗口布局改变、热区切换、页面跳转、光标移出再回到窗口、光标在窗口不同区域移动,以上场景可能导致光标切换回系统样式,需要开发者重新设置光标样式。

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

参数

参数名 类型 必填 说明
windowId number 窗口id。
cursor CustomCursor 自定义光标资源。
config CursorConfig 自定义光标配置,用于配置是否根据系统设置调整光标大小。如果CursorConfig中followSystem设置为true,则光标大小的可调整范围为:[光标资源图大小,256×256]。

返回值

类型 说明
Promise&lt;void&gt; 无返回结果的Promise对象。

错误码

以下错误码的详细介绍请参见通用错误码输入设备错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Abnormal windowId parameter passed in. 2. Abnormal pixelMap parameter passed in; 3. Abnormal focusX parameter passed in.4. Abnormal focusY parameter passed in.
26500001 Invalid windowId. Possible causes: The window id does not belong to the current process.

示例

import { image } from '@kit.ImageKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';

// app_icon为示例资源,请开发者根据实际需求配置资源文件。
this.getUIContext()?.getHostContext()?.resourceManager.getMediaContent($r("app.media.app_icon")).then((svgFileData) => {
  const svgBuffer: ArrayBuffer = svgFileData.buffer.slice(0);
  let svgImagesource: image.ImageSource = image.createImageSource(svgBuffer);
  let svgDecodingOptions: image.DecodingOptions = {desiredSize: { width: 50, height:50 }};
  svgImagesource.createPixelMap(svgDecodingOptions).then((pixelMap) => {
    window.getLastWindow(this.getUIContext().getHostContext(), (error: BusinessError, win: window.Window) => {
      let windowId = win.getWindowProperties().id;
        try {
          pointer.setCustomCursor(windowId, {pixelMap: pixelMap, focusX: 25, focusY: 25}, {followSystem: false}).then(() => {
            console.log(`setCustomCursor success`);
          });
        } catch (error) {
          console.error(`setCustomCursor failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
        }
      });
  });
});

pointer.setCustomCursorSync11+

setCustomCursorSync(windowId: number, pixelMap: image.PixelMap, focusX?: number, focusY?: number): void

设置自定义光标样式,使用同步方式进行设置。

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

参数

参数名 类型 必填 说明
windowId number 窗口id。取值为大于0的整数。
pixelMap image.PixelMap 自定义光标资源。
focusX number 自定义光标焦点x,取值范围:大于等于0,默认为0。
focusY number 自定义光标焦点y,取值范围:大于等于0,默认为0。

错误码

以下错误码的详细介绍请参见通用错误码

错误码ID 错误信息
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed.

示例

import { image } from '@kit.ImageKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';

// app_icon为示例资源,请开发者根据实际需求配置资源文件。
const svgFileData = this.getUIContext()?.getHostContext()?.resourceManager.getMediaContent($r("app.media.app_icon")).then((svgFileData) => {
  const svgBuffer: ArrayBuffer = svgFileData.buffer.slice(0);
  let svgImagesource: image.ImageSource = image.createImageSource(svgBuffer);
  let svgDecodingOptions: image.DecodingOptions = {desiredSize: { width: 50, height:50 }};
  svgImagesource.createPixelMap(svgDecodingOptions).then((pixelMap) => {
    window.getLastWindow(this.getUIContext().getHostContext(), (error: BusinessError, win: window.Window) => {
      let windowId = win.getWindowProperties().id;
        try {
          pointer.setCustomCursorSync(windowId, pixelMap, 25, 25);
          console.log(`setCustomCursorSync success`);
        } catch (error) {
          console.error(`setCustomCursorSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
        }
    });
  });
});

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Input Kit(多模输入服务)

harmony 鸿蒙Input_AxisEvent

harmony 鸿蒙Input_DeviceInfo

harmony 鸿蒙Input_DeviceListener

harmony 鸿蒙Input_Hotkey

harmony 鸿蒙Input_InterceptorEventCallback

harmony 鸿蒙Input_InterceptorOptions

harmony 鸿蒙Input_KeyEvent

harmony 鸿蒙Input_KeyState

harmony 鸿蒙Input_MouseEvent

0  赞