harmony 鸿蒙@ohos.multimodalInput.touchEvent (Touch Event)

  • 2022-08-09
  • 浏览 (743)

@ohos.multimodalInput.touchEvent (Touch Event)

The touchEvent module provides touchscreen events reported by a device. It is inherited from InputEvent.

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 {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput.touchEvent';

Action

Enumerates touch event types.

System capability: SystemCapability.MultimodalInput.Input.Core

Name Value Description
CANCEL 0 Cancellation of touch.
DOWN 1 Pressing of touch.
MOVE 2 Moving of touch.
UP 3 Lifting of touch.

ToolType

Enumerates touch tool types.

System capability: SystemCapability.MultimodalInput.Input.Core

Name Value Description
FINGER 0 Finger
PEN 1 Stylus
RUBBER 2 Eraser
BRUSH 3 Brush
PENCIL 4 Pencil
AIRBRUSH 5 Air brush
MOUSE 6 Mouse
LENS 7 Lens

SourceType

Enumerates touch source types.

System capability: SystemCapability.MultimodalInput.Input.Core

Name Value Description
TOUCH_SCREEN 0 Touchscreen
PEN 1 Stylus
TOUCH_PAD 2 Touchpad

Touch

Defines the touch point information.

System capability: SystemCapability.MultimodalInput.Input.Core

Name Type Readable Writable Description
id number Yes No Touch event ID.
pressedTime number Yes No Press timestamp, in μs.
screenX number Yes No X coordinate of the touch position on the screen.
screenY number Yes No Y coordinate of the touch position on the screen.
windowX number Yes No X coordinate of the touch position in the window.
windowY number Yes No Y coordinate of the touch position in the window.
pressure number Yes No Pressure value. The value range is [0.0, 1.0]. The value 0.0 indicates that the pressure is not supported.
width number Yes No Width of the touch area.
height number Yes No Height of the touch area.
tiltX number Yes No Angle relative to the YZ plane. The value range is [-90, 90]. A positive value indicates a rightward tilt.
tiltY number Yes No Angle relative to the XZ plane. The value range is [-90, 90]. A positive value indicates a downward tilt.
toolX number Yes No X coordinate of the center point of the tool area.
toolY number Yes No Y coordinate of the center point of the tool area.
toolWidth number Yes No Width of the tool area.
toolHeight number Yes No Height of the tool area.
rawX number Yes No X coordinate of the input device.
rawY number Yes No Y coordinate of the input device.
toolType ToolType Yes No Tool type.

TouchEvent

Defines a touch event.

System capability: SystemCapability.MultimodalInput.Input.Core

Name Type Readable Writable Description
action Action Yes No Touch event type.
touch Touch Yes No Current touch point.
touches Touch[] Yes No All touch points.
sourceType SourceType Yes No Touch source type.

你可能感兴趣的鸿蒙文章

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)

0  赞