harmony 鸿蒙@ohos.multimodalInput.pointer (Mouse Pointer)

2022-10-28 浏览 (791)

@ohos.multimodalInput.pointer (Mouse Pointer)

The pointer module provides APIs related to pointer attribute management.

NOTE

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.

Modules to Import

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

pointer.setPointerVisible9+

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

Sets the visible status of the mouse pointer. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
visiblebooleanYesWhether the mouse pointer is visible.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setPointerVisible9+

setPointerVisible(visible: boolean): Promise<void>

Sets the visible status of the mouse pointer. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
visiblebooleanYesWhether the mouse pointer is visible.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.setPointerVisibleSync10+

setPointerVisibleSync(visible: boolean): void

Sets the visible status of the mouse pointer. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
visiblebooleanYesWhether the mouse pointer is visible. The value true indicates that the mouse pointer is visible, and the value false indicates the opposite.

Example

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

pointer.isPointerVisible9+

isPointerVisible(callback: AsyncCallback<boolean>): void

Checks the visible status of the mouse pointer. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result.

Example

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

pointer.isPointerVisible9+

isPointerVisible(): Promise<boolean>

Checks the visible status of the mouse pointer. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Return value

NameDescription
Promise<boolean>Promise used to return the result.

Example

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

pointer.isPointerVisibleSync10+

isPointerVisibleSync(): boolean

Obtains the visible status of the mouse pointer. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Return value

NameDescription
booleanVisible status of the mouse pointer.

Example

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

pointer.setPointerSpeed9+

setPointerSpeed(speed: number, callback: AsyncCallback<void>): void

Sets the moving speed of the mouse pointer. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
speednumberYesMoving speed of the mouse pointer. The value ranges from 1 to 11. The default value is 5.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setPointerSpeed9+

setPointerSpeed(speed: number): Promise<void>

Sets the moving speed of the mouse pointer. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
speednumberYesMoving speed of the mouse pointer. The value ranges from 1 to 11. The default value is 5.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.setPointerSpeedSync10+

setPointerSpeedSync(speed: number): void

Sets the moving speed of the mouse pointer. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
speednumberYesMoving speed of the mouse pointer. The value ranges from 1 to 11. The default value is 5.

Example

try {
  let speed = pointer.setPointerSpeedSync(5);
  console.log(`Set pointer speed success`);
} catch (error) {
  console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getPointerSpeed9+

getPointerSpeed(callback: AsyncCallback<number>): void

Obtains the moving speed of the mouse pointer. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<number>YesCallback used to return the result.

Example

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

pointer.getPointerSpeed9+

getPointerSpeed(): Promise<number>

Obtains the moving speed of the mouse pointer. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<number>Promise used to return the result.

Example

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

pointer.getPointerSpeedSync10+

getPointerSpeedSync(): number

Obtains the moving speed of the mouse pointer. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
numberMoving speed of the mouse pointer.

Example

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

pointer.setHoverScrollState10+

setHoverScrollState(state: boolean, callback: AsyncCallback<void>): void

Sets the status of the mouse hover scroll switch. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesStatus of the mouse hover scroll switch.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setHoverScrollState10+

setHoverScrollState(state: boolean): Promise<void>

Sets the status of the mouse hover scroll switch. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesStatus of the mouse hover scroll switch.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getHoverScrollState10+

getHoverScrollState(callback: AsyncCallback<boolean>): void

Obtains the status of the mouse hover scroll switch. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result.

Example

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

pointer.getHoverScrollState10+

getHoverScrollState(): Promise<boolean>

Obtains the status of the mouse hover scroll switch. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<boolean>Promise used to return the result.

Example

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

pointer.setMousePrimaryButton10+

setMousePrimaryButton(primary: PrimaryButton, callback: AsyncCallback<void>): void

Sets the primary button of the mouse. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
primaryPrimaryButtonYesID of the primary mouse button.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setMousePrimaryButton10+

setMousePrimaryButton(primary: PrimaryButton): Promise<void>

Sets the primary button of the mouse. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
primaryPrimaryButtonYesID of the primary mouse button.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getMousePrimaryButton10+

getMousePrimaryButton(callback: AsyncCallback<PrimaryButton>): void

Obtains the primary button of the mouse. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<PrimaryButton>YesCallback used to return the result.

Example

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

pointer.getMousePrimaryButton10+

getMousePrimaryButton(): Promise<PrimaryButton>

Obtains the primary button of the mouse. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<PrimaryButton>Promise used to return the result.

Example

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

PrimaryButton10+

Type of the primary mouse button.

System capability: SystemCapability.MultimodalInput.Input.Pointer

NameValueDescription
LEFT0Left mouse button.
RIGHT1Right mouse button.

pointer.setMouseScrollRows10+

setMouseScrollRows(rows: number, callback: AsyncCallback<void>): void

Sets the number of mouse scroll rows. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
rowsnumberYesNumber of mouse scroll rows. The value ranges from 1 to 100. The default value is 3.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setMouseScrollRows10+

setMouseScrollRows(rows: number): Promise<void>

Sets the number of mouse scroll rows. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
rowsnumberYesNumber of mouse scroll rows. The value ranges from 1 to 100. The default value is 3.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getMouseScrollRows10+

getMouseScrollRows(callback: AsyncCallback<number>): void

Obtains the number of mouse scroll rows. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<number>YesCallback used to return the result.

Example

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

pointer.getMouseScrollRows10+

getMouseScrollRows(): Promise<number>

Obtains the moving speed of the mouse pointer. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<number>Promise used to return the result.

Example

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

pointer.getPointerStyle9+

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

Obtains the mouse pointer style. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
windowIdnumberYesWindow ID.
callbackAsyncCallback<PointerStyle>YesCallback used to return the result.

Example

import { BusinessError }  from '@ohos.base';
import window from '@ohos.window';

let context = getContext(this);
window.getLastWindow(context, (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.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

pointer.getPointerStyle9+

getPointerStyle(windowId: number): Promise<PointerStyle>

Obtains the mouse pointer style. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
windowIdnumberYesWindow ID.

Return value

NameDescription
Promise<PointerStyle>Promise used to return the result.

Example

import window from '@ohos.window';
import { BusinessError }  from '@ohos.base';

let context = getContext(this);
window.getLastWindow(context, (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.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

pointer.getPointerStyleSync10+

getPointerStyleSync(windowId: number): PointerStyle

Obtains the mouse pointer style. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
windowIdnumberYesWindow ID.

Return value

NameDescription
PointerStyleMouse pointer style.

Example

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

pointer.setPointerStyle9+

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

Sets the mouse pointer style. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
windowIdnumberYesWindow ID.
pointerStylePointerStyleYesMouse pointer style ID.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

import window from '@ohos.window';
import { BusinessError }  from '@ohos.base';

window.getLastWindow(getContext(), (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.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

pointer.setPointerStyle9+

setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise<void>

Sets the mouse pointer style. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
windowIdnumberYesWindow ID.
pointerStylePointerStyleYesMouse pointer style ID.
Promise<void>voidYesPromise used to return the result.

Example

import window from '@ohos.window';
import { BusinessError }  from '@ohos.base';

window.getLastWindow(getContext(), (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.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

pointer.setPointerStyleSync10+

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

Sets the mouse pointer style. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

Parameters

NameTypeMandatoryDescription
windowIdnumberYesWindow ID.
pointerStylePointerStyleYesMouse pointer style ID.

Example

import window from '@ohos.window';
import { BusinessError }  from '@ohos.base';

window.getLastWindow(getContext(), (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.log(`getPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
  }
});

PointerStyle9+

Enumerates mouse pointer styles.

System capability: SystemCapability.MultimodalInput.Input.Pointer

NameValueDescriptionLegend
DEFAULT0DefaultDefault.png
EAST1East arrowEast.png
WEST2West arrowWest.png
SOUTH3South arrowSouth.png
NORTH4North arrowNorth.png
WEST_EAST5West-east arrowWest_East.png
NORTH_SOUTH6North-south arrowNorth_South.png
NORTH_EAST7North-east arrowNorth_East.png
NORTH_WEST8North-west arrowNorth_West.png
SOUTH_EAST9South-east arrowSouth_East.png
SOUTH_WEST10South-west arrowSouth_West.png
NORTH_EAST_SOUTH_WEST11North-east and south-west adjustmentNorth_East_South_West.png
NORTH_WEST_SOUTH_EAST12North-west and south-east adjustmentNorth_West_South_East.png
CROSS13Cross (accurate selection)Cross.png
CURSOR_COPY14CopyCopy.png
CURSOR_FORBID15ForbidForbid.png
COLOR_SUCKER16SuckerColorsucker.png
HAND_GRABBING17Grabbing handHand_Grabbing.png
HAND_OPEN18Opening handHand_Open.png
HAND_POINTING19Hand-shaped pointerHand_Poniting.png
HELP20HelpHelp.png
MOVE21MoveMove.png
RESIZE_LEFT_RIGHT22Left and right resizingResize_Left_Right.png
RESIZE_UP_DOWN23Up and down resizingResize_Up_Down.png
SCREENSHOT_CHOOSE24Screenshot crosshairScreenshot_Cross.png
SCREENSHOT_CURSOR25ScreenshotScreenshot_Cursor.png
TEXT_CURSOR26Text selectionText_Cursor.png
ZOOM_IN27Zoom inZoom_In.png
ZOOM_OUT28Zoom outZoom_Out.png
MIDDLE_BTN_EAST29Scrolling eastMID_Btn_East.png
MIDDLE_BTN_WEST30Scrolling westMID_Btn_West.png
MIDDLE_BTN_SOUTH31Scrolling southMID_Btn_South.png
MIDDLE_BTN_NORTH32Scrolling northMID_Btn_North.png
MIDDLE_BTN_NORTH_SOUTH33Scrolling north-southMID_Btn_North_South.png
MIDDLE_BTN_NORTH_EAST34Scrolling north-eastMID_Btn_North_East.png
MIDDLE_BTN_NORTH_WEST35Scrolling north-westMID_Btn_North_West.png
MIDDLE_BTN_SOUTH_EAST36Scrolling south-eastMID_Btn_South_East.png
MIDDLE_BTN_SOUTH_WEST37Scrolling south-westMID_Btn_South_West.png
MIDDLE_BTN_NORTH_SOUTH_WEST_EAST38Moving as a cone in four directionsMID_Btn_North_South_West_East.png
HORIZONTAL_TEXT_CURSOR10+39Horizontal text selectionHorizontal_Text_Cursor.png
CURSOR_CROSS10+40CrossCursor_Cross.png
CURSOR_CIRCLE10+41CircleCursor_Circle.png
LOADING10+42Animation loadingLoading.png
RUNNING10+43Animation running in the backgroundRunning.png

pointer.setTouchpadScrollSwitch10+

setTouchpadScrollSwitch(state: boolean, callback: AsyncCallback<void>): void

Sets the scroll switch of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesScroll switch status. The value true indicates that the scroll switch is enabled, and the value false indicates the opposite. The default value is true.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setTouchpadScrollSwitch10+

setTouchpadScrollSwitch(state: boolean): Promise<void>

Sets the scroll switch of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesScroll switch status. The value true indicates that the scroll switch is enabled, and the value false indicates the opposite. The default value is true.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getTouchpadScrollSwitch10+

getTouchpadScrollSwitch(callback: AsyncCallback<boolean>): void

Obtains the scroll switch status of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result.

Example

try {
  pointer.getTouchpadScrollSwitch((error: Error, state: Boolean) => {
    console.log(`getTouchpadScrollSwitch success, state: ${JSON.stringify(state)}`);
  });
} catch (error) {
  console.log(`getTouchpadScrollSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getTouchpadScrollSwitch10+

getTouchpadScrollSwitch(): Promise<boolean>

Obtains the scroll switch status of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<boolean>Promise used to return the result.

Example

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

pointer.setTouchpadScrollDirection10+

setTouchpadScrollDirection(state: boolean, callback: AsyncCallback<void>): void

Sets the scroll direction of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesScroll direction of the touchpad. The value true indicates that the scroll direction is the same as the finger moving direction, and the value false indicates the opposite. The default value is true.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setTouchpadScrollDirection10+

setTouchpadScrollDirection(state: boolean): Promise<void>

Sets the scroll direction of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesScroll direction of the touchpad. The value true indicates that the scroll direction is the same as the finger moving direction, and the value false indicates the opposite. The default value is true.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getTouchpadScrollDirection10+

getTouchpadScrollDirection(callback: AsyncCallback<boolean>): void

Obtains the scroll direction of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result.

Example

try {
  pointer.getTouchpadScrollDirection ((error: Error, state: Boolean) => {
    console.log(`getTouchpadScrollDirection success, state: ${JSON.stringify(state)}`);
  });
} catch (error) {
  console.log(`getTouchpadScrollDirection failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getTouchpadScrollDirection10+

getTouchpadScrollDirection(): Promise<boolean>

Obtains the scroll direction of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<boolean>Promise used to return the result.

Example

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

pointer.setTouchpadTapSwitch10+

setTouchpadTapSwitch(state: boolean, callback: AsyncCallback<void>): void

Sets the tap switch of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesTap switch status of the touchpad The value true indicates that the tap switch is enabled, and the value false indicates the opposite. The default value is true.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setTouchpadTapSwitch 10+

setTouchpadTapSwitch(state: boolean): Promise<void>

Sets the tap switch of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesTap switch status of the touchpad The value true indicates that the tap switch is enabled, and the value false indicates the opposite. The default value is true.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getTouchpadTapSwitch10+

getTouchpadTapSwitch(callback: AsyncCallback<boolean>): void

Obtains the tap switch status of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result.

Example

try {
  pointer.getTouchpadTapSwitch((error: Error, state: Boolean) => {
    console.log(`getTouchpadTapSwitch success, state: ${JSON.stringify(state)}`);
  });
} catch (error) {
  console.log(`getTouchpadTapSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getTouchpadTapSwitch10+

getTouchpadTapSwitch(): Promise<boolean>

Obtains the tap switch status of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<boolean>Promise used to return the result.

Example

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

pointer.setTouchpadPointerSpeed10+

setTouchpadPointerSpeed(speed: number, callback: AsyncCallback<void>): void

Sets the mouse pointer moving speed of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
speednumberYesMouse pointer moving speed of the touchpad. The value range is [1,11]. The default value is 5.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setTouchpadPointerSpeed10+

setTouchpadPointerSpeed(speed: number): Promise<void>

Sets the mouse pointer moving speed of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
speednumberYesMouse pointer moving speed of the touchpad. The value range is [1,11]. The default value is 5.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getTouchpadPointerSpeed10+

getTouchpadPointerSpeed(callback: AsyncCallback<number>): void

Obtains the mouse pointer moving speed of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<number>YesCallback used to return the result.

Example

try {
  pointer.getTouchpadPointerSpeed((error: Error, speed: Number) => {
    console.log(`getTouchpadPointerSpeed success, speed: ${JSON.stringify(speed)}`);
  });
} catch (error) {
  console.log(`getTouchpadPointerSpeed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getTouchpadPointerSpeed10+

getTouchpadPointerSpeed(): Promise<number>

Obtains the mouse pointer moving speed of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<number>Promise used to return the result.

Example

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

pointer.setTouchpadPinchSwitch10+

setTouchpadPinchSwitch(state: boolean, callback: AsyncCallback<void>): void

Sets the pinch switch of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesPinch switch status of the touchpad. The value true indicates that the pinch switch is enabled, and the value false indicates the opposite. The default value is true.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setTouchpadPinchSwitch10+

setTouchpadPinchSwitch(state: boolean): Promise<void>

Sets the pinch switch of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesPinch switch status of the touchpad. The value true indicates that the pinch switch is enabled, and the value false indicates the opposite. The default value is true.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getTouchpadPinchSwitch10+

getTouchpadPinchSwitch(callback: AsyncCallback<boolean>): void

Obtains the pinch switch status of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result.

Example

try {
  pointer.getTouchpadPinchSwitch((error: Error, state: Boolean) => {
    console.log(`getTouchpadPinchSwitch success, state: ${JSON.stringify(state)}`);
  });
} catch (error) {
  console.log(`getTouchpadPinchSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getTouchpadPinchSwitch10+

getTouchpadPinchSwitch(): Promise<boolean>

Obtains the pinch switch status of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<boolean>Promise used to return the result.

Example

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

pointer.setTouchpadSwipeSwitch10+

setTouchpadSwipeSwitch(state: boolean, callback: AsyncCallback<void>): void

Sets the multi-finger swipe switch of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesSwipe switch status of the touchpad. The value true indicates that the swipe switch is enabled, and the value false indicates the opposite. The default value is true.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setTouchpadSwipeSwitch10+

setTouchpadSwipeSwitch(state: boolean): Promise<void>

Sets the swipe switch of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
statebooleanYesSwipe switch status of the touchpad. The value true indicates that the swipe switch is enabled, and the value false indicates the opposite. The default value is true.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getTouchpadSwipeSwitch10+

getTouchpadSwipeSwitch(callback: AsyncCallback<boolean>): void

Obtains the multi-finger swipe switch status of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<boolean>YesCallback used to return the result.

Example

try {
  pointer.getTouchpadSwipeSwitch((error: Error, state: Boolean) => {
    console.log(`getTouchpadSwipeSwitch success, state: ${JSON.stringify(state)}`);
  });
} catch (error) {
  console.log(`getTouchpadSwipeSwitch failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getTouchpadSwipeSwitch10+

getTouchpadSwipeSwitch(): Promise<boolean>

Obtains the multi-finger swipe switch status of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<boolean>Promise used to return the result.

Example

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

RightClickType10+

Enumerates shortcut menu triggering modes.

System capability: SystemCapability.MultimodalInput.Input.Pointer

NameValueDescription
TOUCHPAD_RIGHT_BUTTON1Tapping the right-button area of the touchpad.
TOUCHPAD_LEFT_BUTTON2Tapping the left-button area of the touchpad.
TOUCHPAD_TWO_FINGER_TAP3Tapping or pressing the touchpad with two fingers.

pointer.setTouchpadRightClickType10+

setTouchpadRightClickType(type: RightClickType, callback: AsyncCallback<void>): void

Sets the shortcut menu type of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
typeRightClickTypeYesShortcut menu type of the touchpad.
- TOUCHPAD_RIGHT_BUTTON: tapping the right-button area of the touchpad.
- TOUCHPAD_LEFT_BUTTON: tapping the left-button area of the touchpad.
- TOUCHPAD_TWO_FINGER_TAP: tapping or pressing the touchpad with two fingers.
The default value is TOUCHPAD_RIGHT_BUTTON.
callbackAsyncCallback<void>YesCallback used to return the result.

Example

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

pointer.setTouchpadRightClickType10+

setTouchpadRightClickType(type: RightClickType): Promise<void>

Sets the shortcut menu type of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
typeRightClickTypeYesShortcut menu type of the touchpad.
- TOUCHPAD_RIGHT_BUTTON: tapping the right-button area of the touchpad.
- TOUCHPAD_LEFT_BUTTON: tapping the left-button area of the touchpad.
- TOUCHPAD_TWO_FINGER_TAP: tapping or pressing the touchpad with two fingers.
The default value is TOUCHPAD_RIGHT_BUTTON.

Return value

NameDescription
Promise<void>Promise used to return the result.

Example

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

pointer.getTouchpadRightClickType10+

getTouchpadRightClickType(callback: AsyncCallback<RightClickType>): void

Obtains the shortcut menu type of the touchpad. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<RightClickType>YesCallback used to return the result.

Example

try {
  pointer.getTouchpadRightClickType((error: Error, type: pointer.RightClickType) => {
    console.log(`getTouchpadRightClickType success, type: ${JSON.stringify(type)}`);
  });
} catch (error) {
  console.log(`getTouchpadRightClickType failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getTouchpadRightClickType10+

getTouchpadRightClickType(): Promise<RightClickType>

Obtains the shortcut menu type of the touchpad. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<RightClickType >Promise used to return the result.

Example

try {
  pointer.getTouchpadRightClickType().then((type: pointer.RightClickType) => {
    console.log(`getTouchpadRightClickType success, typeed: ${JSON.stringify(type)}`);
  });
} catch (error) {
  console.log(`getTouchpadRightClickType failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.setPointerSize10+

setPointerSize(size: number, callback: AsyncCallback<void>): void

Sets the pointer size. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
sizenumberYesPointer size. The value ranges from 1 to 7. The default value is 1.
callbackAsyncCallback<void>YesCallback used to return the result. If the operation is successful, err is undefined. Otherwise, err is an error object.

Example

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

pointer.setPointerSize10+

setPointerSize(size: number): Promise<void>

Sets the pointer size. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
sizenumberYesPointer size. The value ranges from 1 to 7. The default value is 1.

Return value

NameDescription
Promise<void>Promise that returns no value.

Example

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

pointer.setPointerSizeSync10+

setPointerSizeSync(size: number): void;

Sets the pointer size. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
sizenumberYesPointer size. The value ranges from 1 to 7. The default value is 1.

Example

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

pointer.getPointerSize10+

getPointerSize(callback: AsyncCallback<number>): void

Obtains the pointer size. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<number>YesCallback used to return the result.

Example

try {
  pointer.getPointerSize((error: Error, size: Number) => {
    console.log(`getPointerSize success, size: ${JSON.stringify(size)}`);
  });
} catch (error) {
  console.log(`getPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getPointerSize10+

getPointerSize(): Promise<number>

Obtains the pointer size. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<number>Promise used to return the result.

Example

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

pointer.getPointerSizeSync10+

getPointerSizeSync(): number

Obtains the pointer size. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
numberPointer size.

Example

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

pointer.setPointerColor10+

setPointerColor(color: number, callback: AsyncCallback<void>): void

Sets the pointer color. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
colornumberYesPointer color. The default value is black (0x000000).
callbackAsyncCallback<void>YesCallback used to return the result. If the operation is successful, err is undefined. Otherwise, err is an error object.

Example

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

pointer.setPointerColor10+

setPointerColor(color: number): Promise<void>

Sets the pointer color. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
colornumberYesPointer color. The default value is black (0x000000).

Return value

NameDescription
Promise<void>Promise that returns no value.

Example

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

pointer.setPointerColorSync10+

setPointerColorSync(color: number): void;

Sets the pointer color. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
colornumberYesPointer color. The default value is black (0x000000).

Example

try {
  pointer.setPointerColorSync(0xF6C800);
  console.log(`setPointerColorSync success`);
} catch (error) {
  console.log(`setPointerColorSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getPointerColor10+

getPointerColor(callback: AsyncCallback<number>): void

Obtains the pointer color. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<number>YesCallback used to return the result.

Example

try {
  pointer.getPointerColor((error: Error, color: Number) => {
    console.log(`getPointerColor success, color: ${JSON.stringify(color)}`);
  });
} catch (error) {
  console.log(`getPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

pointer.getPointerColor10+

getPointerColor(): Promise<number>

Obtains the pointer color. This API uses a promise to return the result.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
Promise<number>Promise used to return the result.

Example

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

pointer.getPointerColorSync10+

getPointerColorSync(): number

Obtains the pointer color. This API returns the result synchronously.

System capability: SystemCapability.MultimodalInput.Input.Pointer

System API: This is a system API.

Return value

NameDescription
numberPointer color.

Example

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

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events (To Be Deprecated Soon)

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/4b8d0b2e7a0b48c984ccc2c099929390