• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.multimodalInput.touchEvent (Touch Event)
2
3The **touchEvent** module provides touch events reported by an input device.
4
5> **NOTE**<br>
6> 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.
7
8## Modules to Import
9
10```js
11import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput.touchEvent';
12```
13
14## Action
15
16Enumerates touch actions.
17
18**System capability**: SystemCapability.MultimodalInput.Input.Core
19
20| Name   | Value | Description |
21| ------ | ----- | ----------- |
22| CANCEL | 0 | Cancellation of the touch action.|
23| DOWN   | 1 | Pressing of touch.               |
24| MOVE   | 2 | Moving of touch.                 |
25| UP     | 3 | Lifting of touch.                |
26
27## ToolType
28
29Enumerates tool types.
30
31**System capability**: SystemCapability.MultimodalInput.Input.Core
32
33| Name | Value | Description |
34| ---- | ----- | ----------- |
35| FINGER | 0 | Finger|
36| PEN | 1 | Pen|
37| RUBBER | 2 | Eraser|
38| BRUSH | 3 | Brush|
39| PENCIL | 4 | Pencil|
40| AIRBRUSH | 5 | Air brush|
41| MOUSE | 6 | Mouse|
42| LENS | 7 | Lens|
43
44## SourceType
45
46Enumerates source types.
47
48**System capability**: SystemCapability.MultimodalInput.Input.Core
49
50| Name | Value | Description |
51| ---- | ----- | ----------- |
52| TOUCH_SCREEN | 0 | Touchscreen|
53| PEN          | 1 | Stylus     |
54| TOUCH_PAD    | 2 | Touchpad   |
55
56## Touch
57
58Defines a touch action.
59
60**System capability**: SystemCapability.MultimodalInput.Input.Core
61
62| Name| Type| Readable| Writable| Description|
63| -------- | -------- | -------- | -------- | -------- |
64| id | number | Yes| No| Pointer ID.|
65| pressedTime  | number | Yes| No| Time stamp when touch is pressed.|
66| screenX | number | Yes| No| X coordinate of the touch position on the screen.|
67| screenY | number | Yes| No| Y coordinate of the touch position on the screen.|
68| windowX | number | Yes| No| X coordinate of the touch position in the window.|
69| windowY | number | Yes| No| Y coordinate of the touch position in the window.|
70| 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.|
71| width | number | Yes| No| Width of the contact area where touch is pressed.|
72| height | number | Yes| No| Height of the contact area where touch is pressed.|
73| tiltX | number | Yes| No| Angle relative to the YZ plane. The value range is [-90, 90]. A positive value indicates a rightward tilt.|
74| tiltY | number | Yes| No| Angle relative to the XZ plane. The value range is [-90, 90]. A positive value indicates a downward tilt.|
75| toolX | number | Yes| No| Center point X of the tool area.|
76| toolY | number | Yes| No| Center point Y of the tool area.|
77| toolWidth | number | Yes| No| Width of the tool area.|
78| toolHeight | number | Yes| No| Height of the tool area.|
79| rawX | number | Yes| No| X coordinate of the input device.|
80| rawY | number | Yes| No| Y coordinate of the input device.|
81| toolType | ToolType | Yes| No| Tool type.|
82
83## TouchEvent
84
85Defines a touch event.
86
87**System capability**: SystemCapability.MultimodalInput.Input.Core
88
89| Name| Type| Readable| Writable| Description|
90| -------- | -------- | -------- | -------- | -------- |
91| action | Action | Yes| No| Touch action.|
92| touch | Touch | Yes| No| Current touch point.|
93| touches | Touch[] | Yes| No| All touch points.|
94| sourceType | SourceType | Yes| No| Device type of the touch source.|
95