From 3bcee8fe95cb7c73b34ace4370931f025124315e Mon Sep 17 00:00:00 2001 From: wangli Date: Mon, 23 Oct 2023 14:56:46 +0800 Subject: [PATCH] mouseEvent inputEventClient docs modify Signed-off-by: wangli --- .../apis/js-apis-inputeventclient.md | 99 ++++++++++++------- .../reference/apis/js-apis-mouseevent.md | 3 +- 2 files changed, 66 insertions(+), 36 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-inputeventclient.md b/en/application-dev/reference/apis/js-apis-inputeventclient.md index e946116ed2d..b65ca3fee14 100644 --- a/en/application-dev/reference/apis/js-apis-inputeventclient.md +++ b/en/application-dev/reference/apis/js-apis-inputeventclient.md @@ -53,7 +53,7 @@ try { ``` ## inputEventClient.injectMouseEvent11+ -injectMouseEvent({mouseEvent: MouseEvent}): void; +injectMouseEvent(mouseEvent: MouseEventData): void; Injects a mouse/touchpad event. @@ -63,29 +63,33 @@ Injects a mouse/touchpad event. | Name | Type | Mandatory | Description | | -------- | --------------------- | ---- | --------- | -| mouseEvent | [MouseEvent](../apis/js-apis-mouseevent.md) | Yes | Mouse/touchpad event to inject.| +| mouseEvent | [MouseEventData](#mouseeventdata11) | Yes | Mouse/touchpad event to inject.| **Example** ```js try { - let mouseButtonUp = { - action: 2, - screenX: 200, - screenY: 620, - button: 0, - toolType: 1, + let mouseButtonUpData = { + isPressed: true, + keyCode: 2, + keyDownDuration: 0, + isIntercepted: false } - inputEventClient.injectMouseEvent({ mouseEvent: mouseButtonUp }); - - let mouseButtonDown = { - action: 3, - screenX: 200, - screenY: 620, - button: 0, - toolType: 1, + let mouseButtonUp: inputEventClient.MouseEventData = { + mouseEvent: mouseButtonUpData + } + inputEventClient.injectMouseEvent(mouseButtonUp); + + let mouseButtonDownData = { + isPressed: false, + keyCode: 2, + keyDownDuration: 0, + isIntercepted: false + } + let mouseButtonDown: inputEventClient.MouseEventData = { + mouseEvent: mouseButtonDownData }; - inputEventClient.injectMouseEvent({ mouseEvent: mouseButtonDown }); + inputEventClient.injectMouseEvent(mouseButtonDown); } catch (error) { console.log(`Failed to inject MouseEvent, error: ${JSON.stringify(error, [`code`, `message`])}`); } @@ -93,7 +97,7 @@ try { ## inputEventClient.injectTouchEvent11+ -injectTouchEvent({touchEvent: TouchEvent}): void; +injectTouchEvent(touchEvent: TouchEventData): void; Injects a touchscreen event. @@ -103,29 +107,36 @@ Injects a touchscreen event. | Name | Type | Mandatory | Description | | -------- | --------------------- | ---- | --------- | -| touchEvent | [TouchEvent](../apis/js-apis-touchevent.md) | Yes | Touchscreen event to inject.| +| touchEvent | [TouchEventData](#toucheventdata11) | Yes | Touchscreen event to inject.| **Example** ```js try { - let touchEventUp = { - action: 1, - sourceType: 0, - screenX: 200, - screenY: 620, - pressedTime: 0, + let touchEvent = { + screenX: 200, + screenY: 620, + pressedTime: 0, + } + let touchEventUpData = { + action: 1, + sourceType: 0, + touch: touchEvent }; - inputEventClient.injectTouchEvent({ touchEvent: touchEventUp }); - - let touchEventDown = { - action: 3, - sourceType: 0, - screenX: 200, - screenY: 620, - pressedTime: 0, + let touchEventUp: inputEventClient.MouseEventData = { + touchEvent: touchEventUpData + } + inputEventClient.injectTouchEvent(touchEventUp); + + let touchEventDownData = { + action: 3, + sourceType: 0, + touch: touchEvent }; - inputEventClient.injectTouchEvent({ touchEvent: touchEventDown }); + let touchEventDown: inputEventClient.MouseEventData = { + touchEvent: touchEventDownData + } + inputEventClient.injectTouchEvent(touchEventDown); } catch (error) { console.log(`Failed to inject touchEvent, error: ${JSON.stringify(error, [`code`, `message`])}`); } @@ -143,3 +154,23 @@ Represents the key event to inject. | keyCode | number | Yes | No| Keycode value. Currently, only the **KEYCODE_BACK** key is supported.| | keyDownDuration | number | Yes | No| Duration for pressing a key, in μs. | | isIntercepted | boolean | Yes | No| Whether the key event can be intercepted.
The value **true** indicates that the key event can be intercepted, and the value **false** indicates the opposite.| + +## MouseEventData11+ + +Represents the mouse event to inject. + +**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator + +| Name | Type | Readable | Writable | Description | +| --------- | ------ | ---- | ---- | ------- | +| mouseEvent | [MouseEvent](../apis/js-apis-mouseevent.md) | Yes | No | Represents the mouse event to inject. | + +## TouchEventData11+ + +Represents the touch event to inject. + +**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator + +| Name | Type | Readable | Writable | Description | +| --------- | ------ | ---- | ---- | ------- | +| touchEvent | [TouchEvent](../apis/js-apis-touchevent.md) | Yes | No | Represents the touch event to inject. | diff --git a/en/application-dev/reference/apis/js-apis-mouseevent.md b/en/application-dev/reference/apis/js-apis-mouseevent.md index 3acd76a5152..ce42469f0ea 100644 --- a/en/application-dev/reference/apis/js-apis-mouseevent.md +++ b/en/application-dev/reference/apis/js-apis-mouseevent.md @@ -81,9 +81,8 @@ Enumerates tool types. | ------- | ------| ----- | | UNKNOWN11+ | 0 | Unknown. | | MOUSE11+ | 1 | Mouse.| -| TOUCHSCREEN11+ | 2 | Touchscreen.| +| JOYSTICK11+ | 2 | Joystick.| | TOUCHPAD11+ | 3 | Touchpad.| -| JOYSTICK11+ | 4 | Joystick.| ## MouseEvent -- Gitee