diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 133d4c1f3ac5ecf7ecd27ad9b995e1f979da55e3..84fa4352fa8d3ce60b662ce10d5fccc2ac3afabc 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -370,6 +370,7 @@ - [@ohos.deviceInfo (设备信息)](js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager (设备管理)](js-apis-device-manager.md) - [@ohos.geoLocationManager (位置服务)](js-apis-geoLocationManager.md) + - [@ohos.multimodalInput.gestureEvent (手势事件)](js-apis-multimodalinput-gestureevent.md) - [@ohos.multimodalInput.inputConsumer (组合按键)](js-apis-inputconsumer.md) - [@ohos.multimodalInput.inputDevice (输入设备)](js-apis-inputdevice.md) - [@ohos.multimodalInput.inputDeviceCooperate (键鼠穿越)(待停用)](js-apis-cooperate.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md index 900ef473cc913747cf131208c8d9d313f9b3ecab..a444ba50565a8415d49443d747f94cd640019ae5 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -1,6 +1,6 @@ # @ohos.multimodalInput.inputMonitor (输入监听) -输入监听模块,提供了监听输入设备事件(当前支持触摸屏和鼠标)的能力。 +输入监听模块,提供了监听输入设备事件(当前支持触屏、鼠标和触控板手势)的能力。 > **说明:** > @@ -17,11 +17,11 @@ import inputMonitor from '@ohos.multimodalInput.inputMonitor'; ``` -## inputMonitor.on +## inputMonitor.on('touch') -on(type: "touch", receiver: TouchEventReceiver): void +on(type: 'touch', receiver: TouchEventReceiver): void -开始监听全局触屏事件。 +监听全局触屏事件。 **需要权限:** ohos.permission.INPUT_MONITORING @@ -38,7 +38,7 @@ on(type: "touch", receiver: TouchEventReceiver): void ```js try { - inputMonitor.on("touch", (touchEvent) => { + inputMonitor.on('touch', (touchEvent) => { console.log(`Monitor on success ${JSON.stringify(touchEvent)}`); return false; }); @@ -47,11 +47,11 @@ try { } ``` -## inputMonitor.on9+ +## inputMonitor.on('mouse')9+ -on(type: "mouse", receiver: Callback<MouseEvent>): void +on(type: 'mouse', receiver: Callback<MouseEvent>): void -开始监听全局鼠标事件。 +监听全局鼠标事件。 **需要权限:** ohos.permission.INPUT_MONITORING @@ -68,7 +68,7 @@ on(type: "mouse", receiver: Callback<MouseEvent>): void ```js try { - inputMonitor.on("mouse", (mouseEvent) => { + inputMonitor.on('mouse', (mouseEvent) => { console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`); return false; }); @@ -79,11 +79,11 @@ try { -## inputMonitor.off +## inputMonitor.off('touch') -off(type: "touch", receiver?: TouchEventReceiver): void +off(type: 'touch', receiver?: TouchEventReceiver): void -停止监听全局触屏事件。 +取消监听全局触屏事件。 **需要权限:** ohos.permission.INPUT_MONITORING @@ -105,8 +105,8 @@ function callback(touchEvent) { return false; }; try { - inputMonitor.on("touch", callback); - inputMonitor.off("touch", callback); + inputMonitor.on('touch', callback); + inputMonitor.off('touch', callback); console.log(`Monitor off success`); } catch (error) { console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); @@ -120,19 +120,19 @@ function callback(touchEvent) { return false; }; try { - inputMonitor.on("touch", callback); - inputMonitor.off("touch"); + inputMonitor.on('touch', callback); + inputMonitor.off('touch'); console.log(`Monitor off success`); } catch (error) { console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` -## inputMonitor.off9+ +## inputMonitor.off('mouse')9+ -off(type: "mouse", receiver?: Callback<MouseEvent>): void +off(type: 'mouse', receiver?: Callback<MouseEvent>): void -停止监听全局鼠标事件。 +取消监听全局鼠标事件。 **需要权限:** ohos.permission.INPUT_MONITORING @@ -154,8 +154,8 @@ function callback(mouseEvent) { return false; }; try { - inputMonitor.on("mouse", callback); - inputMonitor.off("mouse", callback); + inputMonitor.on('mouse', callback); + inputMonitor.off('mouse', callback); console.log(`Monitor off success`); } catch (error) { console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); @@ -169,8 +169,8 @@ function callback(mouseEvent) { return false; }; try { - inputMonitor.on("mouse", callback); - inputMonitor.off("mouse"); + inputMonitor.on('mouse', callback); + inputMonitor.off('mouse'); console.log(`Monitor off success`); } catch (error) { console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); @@ -201,7 +201,7 @@ try { ```js try { - inputMonitor.on("touch", touchEvent => { + inputMonitor.on('touch', touchEvent => { if (touchEvent.touches.length == 3) { // 当前有三个手指按下 return true; } @@ -211,3 +211,240 @@ try { console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` + +## inputMonitor.on('pinch')10+ + +on(type: 'pinch', receiver: Callback<[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)>): void + +监听全局的触控板捏合事件。 + +**需要权限:** ohos.permission.INPUT_MONITORING + +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| type | string | 是 | 输入设备事件类型,取值“pinch”。 | +| receiver | Callback<[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)> | 是 | 回调函数,异步上报捏合输入事件。 | + + **示例:** + +```js +try { + inputMonitor.on('pinch', (pinchEvent) => { + console.log(`Monitor on success ${JSON.stringify(pinchEvent)}`); + return false; + }); +} catch (error) { + console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputMonitor.off('pinch')10+ + +off(type: 'pinch', receiver?: Callback<[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)>): void + +取消监听全局的触控板捏合事件。 + +**需要权限:** ohos.permission.INPUT_MONITORING + +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| type | string | 是 | 输入设备事件类型,取值“pinch”。 | +| receiver | Callback<[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)> | 否 | 需要取消监听的回调函数,若无此参数,则取消当前应用监听的所有回调函数。 | + +**示例:** + +```js +// 取消监听单个回调函数 +function callback(pinchEvent) { + console.log(`Monitor on success ${JSON.stringify(pinchEvent)}`); + return false; +}; +try { + inputMonitor.on('pinch', callback); + inputMonitor.off('pinch', callback); + console.log(`Monitor off success`); +} catch (error) { + console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +```js +// 取消监听所有回调函数 +function callback(pinchEvent) { + console.log(`Monitor on success ${JSON.stringify(pinchEvent)}`); + return false; +}; +try { + inputMonitor.on('pinch', callback); + inputMonitor.off('pinch'); + console.log(`Monitor off success`); +} catch (error) { + console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputMonitor.on('threeFingersSwipe')10+ + +on(type: 'threeFingersSwipe', receiver: Callback<[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)>): void + +监听全局的触控板三指滑动事件。 + +**需要权限:** ohos.permission.INPUT_MONITORING + +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| type | string | 是 | 输入设备事件类型,取值“threeFingersSwipe”。 | +| receiver | Callback<[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)> | 是 | 回调函数,异步上报三指滑动输入事件。 | + + **示例:** + +```js +try { + inputMonitor.on('threeFingersSwipe', (threeFingersSwipe) => { + console.log(`Monitor on success ${JSON.stringify(threeFingersSwipe)}`); + return false; + }); +} catch (error) { + console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputMonitor.off('threeFingersSwipe')10+ + +off(type: 'threeFingersSwipe', receiver?: Callback<[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)>): void + +取消监听全局的触控板三指滑动事件。 + +**需要权限:** ohos.permission.INPUT_MONITORING + +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| type | string | 是 | 输入设备事件类型,取值“threeFingersSwipe”。 | +| receiver | Callback<[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)> | 否 | 需要取消监听的回调函数,若无此参数,则取消当前应用监听的所有回调函数。 | + +**示例:** + +```js +// 取消监听单个回调函数 +function callback(threeFingersSwipe) { + console.log(`Monitor on success ${JSON.stringify(threeFingersSwipe)}`); + return false; +}; +try { + inputMonitor.on('threeFingersSwipe', callback); + inputMonitor.off("threeFingersSwipe", callback); + console.log(`Monitor off success`); +} catch (error) { + console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +```js +// 取消监听所有回调函数 +function callback(threeFingersSwipe) { + console.log(`Monitor on success ${JSON.stringify(threeFingersSwipe)}`); + return false; +}; +try { + inputMonitor.on("threeFingersSwipe", callback); + inputMonitor.off("threeFingersSwipe"); + console.log(`Monitor off success`); +} catch (error) { + console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputMonitor.on('fourFingersSwipe')10+ + +on(type: 'fourFingersSwipe', receiver: Callback<[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)>): void + +监听全局的触控板四指滑动事件。 + +**需要权限:** ohos.permission.INPUT_MONITORING + +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| type | string | 是 | 输入设备事件类型,取值“fourFingersSwipe”。 | +| receiver | Callback<[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)> | 是 | 回调函数,异步上报四指滑动输入事件。 | + + **示例:** + +```js +try { + inputMonitor.on('fourFingersSwipe', (fourFingersSwipe) => { + console.log(`Monitor on success ${JSON.stringify(fourFingersSwipe)}`); + return false; + }); +} catch (error) { + console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputMonitor.off('fourFingersSwipe')10+ + +off(type: 'fourFingersSwipe', receiver?: Callback<[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)>): void + +取消监听全局的触控板四指滑动事件。 + +**需要权限:** ohos.permission.INPUT_MONITORING + +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| type | string | 是 | 输入设备事件类型,取值“fourFingersSwipe”。 | +| receiver | Callback<[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)> | 否 | 需要取消监听的回调函数,若无此参数,则取消当前应用监听的所有回调函数。 | + +**示例:** + +```js +// 取消监听单个回调函数 +function callback(fourFingersSwipe) { + console.log(`Monitor on success ${JSON.stringify(fourFingersSwipe)}`); + return false; +}; +try { + inputMonitor.on('fourFingersSwipe', callback); + inputMonitor.off('fourFingersSwipe', callback); + console.log(`Monitor off success`); +} catch (error) { + console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +```js +// 取消监听所有回调函数 +function callback(fourFingersSwipe) { + console.log(`Monitor on success ${JSON.stringify(fourFingersSwipe)}`); + return false; +}; +try { + inputMonitor.on('fourFingersSwipe', callback); + inputMonitor.off('fourFingersSwipe'); + console.log(`Monitor off success`); +} catch (error) { + console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-multimodalinput-gestureevent.md b/zh-cn/application-dev/reference/apis/js-apis-multimodalinput-gestureevent.md new file mode 100644 index 0000000000000000000000000000000000000000..9053e248f2d64ac0508b2204f679fcd84095bc91 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-multimodalinput-gestureevent.md @@ -0,0 +1,62 @@ +# @ohos.multimodalInput.gestureEvent (手势输入事件) + +设备上报的手势事件。 + +> **说明:** +> +> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import { Pinch, ThreeFingersSwipe, FourFingersSwipe, ActionType } from '@ohos.multimodalInput.gestureEvent'; +``` + +## Pinch + +捏合事件。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Core + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | ----------- | ---- | ---- | ---------------------------------------- | +| type | [ActionType](#actiontype) | 是 | 否 | 捏合事件类型 | +| scale | number | 是 | 否 | 捏合度,取值范围大于等于0 | + +## ThreeFingersSwipe + +三指滑动事件。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Core + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | ----------- | ---- | ---- | ---------------------------------------- | +| type | [ActionType](#actiontype) | 是 | 否 | 三指滑动事件类型 | +| x | number | 是 | 否 | 坐标x | +| y | number | 是 | 否 | 坐标y | + +## FourFingersSwipe + +四指滑动事件。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Core + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | ----------- | ---- | ---- | ---------------------------------------- | +| type | [ActionType](#actiontype) | 是 | 否 | 四指滑动事件类型 | +| x | number | 是 | 否 | 坐标x | +| y | number | 是 | 否 | 坐标y | + + +## ActionType + +手势事件类型。 + +**系统能力**:SystemCapability.MultimodalInput.Input.Core + +| 名称 | 值 | 说明 | +| ----------- | --- | --------------- | +| CANCEL | 0 | 取消 | +| BEGIN | 1 | 手势开始 | +| UPDATE | 2 | 手势更新 | +| END | 3 | 手势结束 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index 188865f0ed381d064aeab65a013807014b592040..a87005436acc5a397ffcbc5725975153d1ce4c81 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -50,6 +50,7 @@ Image(src: PixelMap | ResourceStr | DrawableDescriptor) | syncLoad8+ | boolean | 设置是否同步加载图片,默认是异步加载。同步加载时阻塞UI线程,不会显示占位图。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置图片是否可复制(SVG图片不支持复制)。
当copyOption设置为非CopyOptions.None时,支持使用长按、鼠标右击、快捷组合键'CTRL+C'等方式进行复制。
默认值:CopyOptions.None
该接口支持在ArkTS卡片中使用。 | | colorFilter9+ | [ColorFilter](ts-types.md#colorfilter9) | 给图像设置颜色滤镜效果。
该接口支持在ArkTS卡片中使用。 | +| draggable(deprecated) | boolean | 设置默认拖拽效果。(不能和[onDragStart](ts-universal-events-drag-drop.md)事件同时使用。)
默认值:false
该接口支持在ArkTS卡片中使用。
**说明:**
从 API version 9 开始支持,从 API version 10 开始废弃,建议使用通用属性[draggable](ts-universal-events-drag-drop.md)替代。 | > **说明:** > diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md index 9e659aabb6d40fc0657b7c7caf572072d0cf8056..defa80d39e3b45a1d38e6ba6620b2e52c8fd526c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -41,7 +41,7 @@ Text(content?: string | Resource) | maxFontSize | number \| string \| [Resource](ts-types.md#resource) | 设置文本最大显示字号。
需配合minFontSize以及maxline或布局大小限制使用,单独设置不生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | textCase | [TextCase](ts-appendix-enums.md#textcase) | 设置文本大小写。
默认值:TextCase.Normal
从API version 9开始,该接口支持在ArkTS卡片中使用。| | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 组件支持设置文本是否可复制粘贴。
默认值:CopyOptions.None
该接口支持在ArkTS卡片中使用。 | -| draggable9+ | boolean | 设置选中文本拖拽效果。
不能和[onDragStart](ts-universal-events-drag-drop.md)事件同时使用;
需配合copyOption一起使用,支持对选中文本的拖拽以及选中内容复制到输入框。
默认值:false | +| draggable(deprecated) | boolean | 设置选中文本拖拽效果。
不能和[onDragStart](ts-universal-events-drag-drop.md)事件同时使用;
需配合copyOption一起使用,支持对选中文本的拖拽以及选中内容复制到输入框。
默认值:false
**说明:**
从 API version 9 开始支持,从 API version 10 开始废弃,建议使用通用属性[draggable](ts-universal-events-drag-drop.md)替代。| | textShadow10+ | [ShadowOptions](ts-universal-attributes-image-effect.md#shadowoptions对象说明) | 设置文字阴影效果。 | | heightAdaptivePolicy10+ | [TextHeightAdaptivePolicy](ts-appendix-enums.md#textheightadaptivepolicy10) | 设置文本自适应高度的方式。
默认值:TextHeightAdaptivePolicy.MAX_LINES_FIRST。
**说明:**
当设置为TextHeightAdaptivePolicy.MAX_LINES_FIRST时,优先使用`maxLines`属性来调整文本高度。如果使用`maxLines`属性的布局大小超过了布局约束,则尝试在`minFontSize`和`maxFontSize`的范围内缩小字体以显示更多文本。
当设置为TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST时,优先使用`minFontSize`属性来调整文本高度。如果使用`minFontSize`属性可以将文本布局在一行中,则尝试在`minFontSize`和`maxFontSize`的范围内增大字体并使用最大可能的字体大小。
当设置为TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST时,优先使用布局约束来调整文本高度。如果布局大小超过布局约束,则尝试在`minFontSize`和`maxFontSize`的范围内缩小字体以满足布局约束。如果将字体大小缩小到`minFontSize`后,布局大小仍然超过布局约束,则删除超过布局约束的行。| | textIndent10+ | number \| string | 设置首行文本缩进,默认值0。 |