diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 1ce323236c6b0197cedb9c2856b45fd1b3c23749..38ae408c14cb10ee565a25b714c8f609e64b6bcc 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -335,6 +335,7 @@ - [@ohos.multimodalInput.mouseEvent (鼠标输入事件)](js-apis-mouseevent.md) - [@ohos.multimodalInput.pointer (鼠标指针)](js-apis-pointer.md) - [@ohos.multimodalInput.touchEvent (触摸输入事件)](js-apis-touchevent.md) + - [@ohos.multimodalInput.shortKey (快捷键)](js-apis-shortKey.md) - [@ohos.power (系统电源管理)](js-apis-power.md) - [@ohos.runningLock (Runninglock锁)](js-apis-runninglock.md) - [@ohos.sensor (传感器)](js-apis-sensor.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-pointer.md b/zh-cn/application-dev/reference/apis/js-apis-pointer.md index d4fdde6403d39a226b15e0ac994b74b8aecbd190..209db4eefc24ddca96872f4acb378115d8244eed 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-pointer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pointer.md @@ -258,6 +258,386 @@ try { } ``` +## pointer.setHoverScrollState10+ + +setHoverScrollState(state: boolean, callback: AsyncCallback<void>): void + +设置鼠标悬停滚动开关状态,使用AsyncCallback异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------- | +| state | boolean | 是 | 鼠标悬停滚动开关状态。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例**: + +```js +try { + pointer.setHoverScrollState(true, (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> + +设置鼠标悬停滚动开关状态,使用Promise异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----------------------------------- | +| state | boolean | 是 | 鼠标悬停滚动开关状态。 | + +**返回值**: + +| 参数 | 说明 | +| ------------------- | ---------------- | +| Promise<void> | Promise对象。 | + +**示例**: + +```js +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 + +获取鼠标悬停滚动开关状态,使用AsyncCallback异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数,异步返回鼠标悬停滚动开关状态。 | + +**示例**: + +```js +try { + pointer.getHoverScrollState((error, state) => { + 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> + +获取当前鼠标悬停滚动开关状态,使用Promise异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**返回值**: + +| 参数 | 说明 | +| --------------------- | ------------------- | +| Promise<boolean> | Promise实例,异步返回鼠标悬停滚动开关状态。 | + +**示例**: + +```js +try { + pointer.getHoverScrollState().then((state) => { + 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 + +设置鼠标主键,使用AsyncCallback异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------- | +| primary | [PrimaryButton](#PrimaryButton10) | 是 | 鼠标主键id。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例**: + +```js +try { + pointer.setMousePrimaryButton(pointer.PrimaryButton.RIGHT, (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> + +设置鼠标主键,使用Promise异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----------------------------------- | +| primary | [PrimaryButton](#PrimaryButton10) | 是 | 鼠标主键id。 | + +**返回值**: + +| 参数 | 说明 | +| ------------------- | ---------------- | +| Promise<void> | Promise对象。 | + +**示例**: + +```js +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 + +获取鼠标主键,使用AsyncCallback异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------- | +| callback | AsyncCallback<[PrimaryButton](#PrimaryButton10)> | 是 | 回调函数,异步返回鼠标主键。 | + +**示例**: + +```js +try { + pointer.getMousePrimaryButton((error, primary) => { + 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> + +获取当前鼠标主键,使用Promise异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**返回值**: + +| 参数 | 说明 | +| --------------------- | ------------------- | +| Promise<[PrimaryButton](#PrimaryButton10)> | Promise实例,异步返回鼠标主键。 | + +**示例**: + +```js +try { + pointer.getMousePrimaryButton().then((primary) => { + 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+ + +鼠标主键类型。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +| 名称 | 值 | 说明 | +| -------------------------------- | ---- | ------ | +| LEFT | 0 | 鼠标左键 | +| RIGHT | 1 | 鼠标右键 | + +## pointer.setMouseScrollRows10+ + +setMouseScrollRows(rows: number, callback: AsyncCallback<void>): void + +设置鼠标滚动行数,使用AsyncCallback异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------- | +| rows | number | 是 | 鼠标滚动行数,范围1-100,默认为3。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例**: + +```js +try { + pointer.setMouseScrollRows(1, (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(speed: number): Promise<void> + +设置鼠标滚动行数,使用Promise异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----------------------------------- | +| rows | number | 是 | 鼠标滚动行数,范围1-100,默认为3。 | + +**返回值**: + +| 参数 | 说明 | +| ------------------- | ---------------- | +| Promise<void> | Promise对象。 | + +**示例**: + +```js +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 + +获取鼠标滚动行数,使用AsyncCallback异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------- | +| callback | AsyncCallback<number> | 是 | 回调函数,异步返回鼠标滚动行数。 | + +**示例**: + +```js +try { + pointer.getMouseScrollRows((error, rows) => { + 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> + +获取当前鼠标滚动行数,使用Promise异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Pointer + +**系统API**: 此接口为系统接口。 + +**返回值**: + +| 参数 | 说明 | +| --------------------- | ------------------- | +| Promise<number> | Promise实例,异步返回鼠标滚动行数。 | + +**示例**: + +```js +try { + pointer.getMouseScrollRows().then((rows) => { + 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 diff --git a/zh-cn/application-dev/reference/apis/js-apis-shortKey.md b/zh-cn/application-dev/reference/apis/js-apis-shortKey.md new file mode 100644 index 0000000000000000000000000000000000000000..3b2728052e9d5ec3aec2b510a20e0542107f203e --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-shortKey.md @@ -0,0 +1,81 @@ +# @ohos.multimodalInput.shortKey(快捷键) + +快捷键拉起Ability模块,用于处理快捷键拉起Ability相关能力 + +> **说明:** +> +> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 本模块接口为系统接口。 + +## 导入模块 + +``` +import shortKey from '@ohos.multimodalInput.shortKey'; +``` + +## shortKey.setKeyDownDuration + +setKeyDownDuration(businessId: string, delay: number, callback: AsyncCallback): void + +设置快捷键拉起Ability的延时时间,使用AsyncCallback异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.ShortKey + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------- | ---- | ------------------------------------------------------------ | +| businessId | string | 是 | 业务在多模侧注册的唯一标识,与ability_launch_config.json中的businessId对应 | +| delay | number | 是 | 如果是按下触发,则这个值有效,表示最终按键按下多长时间时触发快捷键拉起Ability。单位:毫秒(ms) | +| callback | AsyncCallback | 是 | 回调函数。 | + +**示例**: + +``` +try { + shortKey.setKeyDownDuration("screenshot", 500, (error) => { + if (error) { + console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Set key down duration success`); + }); +} catch (error) { + console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + + + +## shortKey.setKeyDownDuration + +setKeyDownDuration(businessId: string, delay: number): Promise + +设置快捷键拉起Ability的延时时间,使用Promise异步方式返回结果。 + +**系统能力**:SystemCapability.MultimodalInput.Input.ShortKey + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------------------------------------------ | +| businessId | string | 是 | 业务在多模侧注册的唯一标识,与ability_launch_config.json中的businessId对应 | +| delay | number | 是 | 如果是按下触发,则这个值有效,表示最终按键按下多长时间时触发快捷键拉起Ability。单位:毫秒(ms) | + +**返回值**: + +| 参数 | 说明 | +| ------------- | ------------- | +| Promise | Promise对象。 | + +**示例**: + +``` +try { + shortKey.setKeyDownDuration("screenshot", 500).then(() => { + console.log(`Set key down duration success`); + }); +} catch (error) { + console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +```