docs: fix type information for contents.sendInputEvent (#19479)

The `event` type and keyword is reserved by the typescript generator, in the future we should throw an error from the generator if someone uses a reserved interface like that.

This also splits and documents the InputEvent type way better so that TS
users get strong type safety.

Fixes electron/typescript-definitions#36
This commit is contained in:
Samuel Attard 2019-07-26 16:11:50 -07:00 committed by GitHub
parent 48f2807473
commit 12bbbef688
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 31 deletions

View file

@ -1560,9 +1560,9 @@ Enable device emulation with the given parameters.
Disable device emulation enabled by `webContents.enableDeviceEmulation`.
#### `contents.sendInputEvent(event)`
#### `contents.sendInputEvent(inputEvent)`
* `event` Object
* `inputEvent` [MouseInputEvent](structures/mouse-input-event.md) | [MouseWheelInputEvent](structures/mouse-wheel-input-event.md) | [KeyboardInputEvent](structures/keyboard-input-event.md)
* `type` String (**required**) - The type of the event, can be `mouseDown`,
`mouseUp`, `mouseEnter`, `mouseLeave`, `contextMenu`, `mouseWheel`,
`mouseMove`, `keyDown`, `keyUp` or `char`.
@ -1575,34 +1575,6 @@ Sends an input `event` to the page.
**Note:** The [`BrowserWindow`](browser-window.md) containing the contents needs to be focused for
`sendInputEvent()` to work.
For keyboard events, the `event` object also have following properties:
* `keyCode` String (**required**) - The character that will be sent
as the keyboard event. Should only use the valid key codes in
[Accelerator](accelerator.md).
For mouse events, the `event` object also have following properties:
* `x` Integer (**required**)
* `y` Integer (**required**)
* `button` String - The button pressed, can be `left`, `middle`, `right`.
* `globalX` Integer
* `globalY` Integer
* `movementX` Integer
* `movementY` Integer
* `clickCount` Integer
For the `mouseWheel` event, the `event` object also have following properties:
* `deltaX` Integer
* `deltaY` Integer
* `wheelTicksX` Integer
* `wheelTicksY` Integer
* `accelerationRatioX` Integer
* `accelerationRatioY` Integer
* `hasPreciseScrollingDeltas` Boolean
* `canScroll` Boolean
#### `contents.beginFrameSubscription([onlyDirty ,]callback)`
* `onlyDirty` Boolean (optional) - Defaults to `false`.