js-apis-mouseevent.md 4.5 KB
Newer Older
S
shawn_he 已提交
1
# @ohos.multimodalInput.mouseEvent (Mouse Event)
S
shawn_he 已提交
2

S
shawn_he 已提交
3
The **mouseEvent** module provides mouse events reported by an input device.
S
shawn_he 已提交
4

S
shawn_he 已提交
5
> **NOTE**<br>
S
shawn_he 已提交
6 7 8 9 10
> 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

```js
S
shawn_he 已提交
11
import { Action, Button, Axis, AxisValue, MouseEvent } from '@ohos.multimodalInput.mouseEvent';
S
shawn_he 已提交
12 13 14 15 16 17
```

## Action

**System capability**: SystemCapability.MultimodalInput.Input.Core

S
shawn_he 已提交
18 19 20 21 22 23 24 25 26
| Name       | Value| Description                |
| ----------- | -------- | -------------------- |
| CANCEL      | 0   | Cancellation of a mouse action.            |
| MOVE        | 1   | Moving of the mouse pointer.            |
| BUTTON_DOWN | 2   | Pressing of a mouse button.        |
| BUTTON_UP   | 3   | Release of a mouse button.        |
| AXIS_BEGIN  | 4   | Beginning of the axis event associated with the mouse.|
| AXIS_UPDATE | 5   | Updating of the axis event associated with the mouse.|
| AXIS_END    | 6   | Ending of the axis event associated with the mouse.|
S
shawn_he 已提交
27 28 29 30 31 32


## Button

**System capability**: SystemCapability.MultimodalInput.Input.Core

S
shawn_he 已提交
33 34 35 36 37 38 39 40 41 42
| Name     | Value | Description   |
| ------- | ------| ----- |
| LEFT    | 0 | Left button on the mouse. |
| MIDDLE  | 1 | Middle button on the mouse. |
| RIGHT   | 2 | Right button on the mouse. |
| SIDE    | 3 | Side button on the mouse.|
| EXTRA   | 4 | Extended button on the mouse.|
| FORWARD | 5 | Forward button on the mouse.|
| BACK    | 6 | Back button on the mouse.|
| TASK    | 7 | Task button on the mouse.|
S
shawn_he 已提交
43 44 45 46 47

## Axis

**System capability**: SystemCapability.MultimodalInput.Input.Core

S
shawn_he 已提交
48 49 50 51 52
| Name               | Value    | Description   |
| ----------------- | ------- | ----- |
| SCROLL_VERTICAL   | 0 | Vertical scroll axis.|
| SCROLL_HORIZONTAL | 1 | Horizontal scroll axis.|
| PINCH             | 2 | Pinch axis.  |
S
shawn_he 已提交
53 54 55 56 57 58


## AxisValue

**System capability**: SystemCapability.MultimodalInput.Input.Core

S
shawn_he 已提交
59 60 61 62
| Name   | Type  | Readable  | Writable  | Description  |
| ----- | ------ | ---- | ---- | ---- |
| axis  | Axis   | Yes   | No   | Axis type. |
| value | number | Yes   | No   | Axis value. |
S
shawn_he 已提交
63 64 65 66 67 68


## MouseEvent

**System capability**: SystemCapability.MultimodalInput.Input.Core

S
shawn_he 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| Name            | Type       | Readable  | Writable  | Description                                      |
| -------------- | ----------- | ---- | ---- | ---------------------------------------- |
| action         | Action      | Yes   | No   | Mouse event action.                                  |
| screenX        | number      | Yes   | No   | Horizontal coordinate of the mouse pointer on the screen.                            |
| screenY        | number      | Yes   | No   | Vertical coordinate of the mouse pointer on the screen.                            |
| windowX        | number      | Yes   | No   | Horizontal coordinate of the mouse pointer in the window.                              |
| windowY        | number      | Yes   | No   | Vertical coordinate of the mouse pointer in the window.                              |
| rawDeltaX      | number      | Yes   | No   | Horizontal coordinate offset relative to the previous reported mouse pointer position.|
| rawDeltaY      | number      | Yes   | No   | Vertical coordinate offset relative to the previous reported mouse pointer position.                         |
| button         | Button      | Yes   | No   | Mouse button                              
| pressedButtons | Button[]    | Yes   | No   | Button being pressed.                             |
| axes           | AxisValue[] | Yes   | No   | All axis data contained in the event.                              |
| pressedKeys    | KeyCode[]   | Yes   | No   | List of pressed keys.                           |
| ctrlKey        | boolean     | Yes   | No   | Whether ctrlKey is being pressed.                       |
| altKey         | boolean     | Yes   | No   | Whether altKey is being pressed.                        |
| shiftKey       | boolean     | Yes   | No   | Whether shiftKey is being pressed.                      |
| logoKey        | boolean     | Yes   | No   | Whether logoKey is being pressed.                       |
| fnKey          | boolean     | Yes   | No   | Whether fnKey is being pressed.                         |
| capsLock       | boolean     | Yes   | No   | Whether capsLock is active.                      |
| numLock        | boolean     | Yes   | No   | Whether numLock is active.                       |
| scrollLock     | boolean     | Yes   | No   | Whether scrollLock is active.                    |