openharmony 鸿蒙 js-apis-touchevent

2025-06-16 浏览 (1)

@ohos.multimodalInput.touchEvent (触摸输入事件)

设备上报的触摸(触屏)事件,继承自InputEvent

说明:

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

导入模块

import { Action,ToolType,SourceType,Touch,TouchEvent } from '@kit.InputKit';

Action

触摸事件类型。

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

名称说明
CANCEL0触摸取消。
DOWN1触摸按下。
MOVE2触摸移动。
UP3触摸抬起。

ToolType

操作触摸的工具类型。

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

名称说明
FINGER0手指。
PEN1笔。
RUBBER2橡皮擦。
BRUSH3笔刷。
PENCIL4铅笔。
AIRBRUSH5气笔。
MOUSE6鼠标。
LENS7透镜。

SourceType

触摸来源的设备类型。

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

名称说明
TOUCH_SCREEN0触摸屏。
PEN1手写笔。
TOUCH_PAD2触控板。

Touch

触摸点信息。

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

名称类型只读可选说明
idnumber触摸事件标识。
pressedTimenumber按下时间戳,单位:μs。
screenXnumber触摸位置所属的屏幕x坐标。
screenYnumber触摸位置所属的屏幕y坐标。
windowXnumber触摸位置在窗口中的x坐标。
windowYnumber触摸位置在窗口中的y坐标。
pressurenumber压力值,取值范围是[0.0, 1.0],0.0表示不支持。
widthnumber触摸区域的宽度。
heightnumber触摸区域的高度。
tiltXnumber相对YZ平面的角度,取值的范围[-90, 90],其中正值是向右倾斜。
tiltYnumber相对XZ平面的角度,取值的范围[-90, 90],其中正值是向下倾斜。
toolXnumber工具区域的中心点x坐标。
toolYnumber工具区域的中心点y坐标。
toolWidthnumber工具区域宽度。
toolHeightnumber工具区域高度。
rawXnumber输入设备上的x坐标。
rawYnumber输入设备上的y坐标。
toolTypeToolType工具类型。

TouchEvent

触屏事件。

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

名称类型只读可选说明
actionAction触屏事件类型。
touchTouch当前触摸点信息。
touchesTouch[]所有触摸点。
sourceTypeSourceType触摸来源的设备类型。

你可能感兴趣的鸿蒙文章

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

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