Merge pull request #10183 from andens/mouse_forward

Mouse forward functionality on Windows
This commit is contained in:
Cheng Zhao 2017-08-17 15:54:22 +09:00 committed by GitHub
commit f908678e8e
8 changed files with 156 additions and 7 deletions

View file

@ -1311,9 +1311,14 @@ Returns `Boolean` - Whether the window is visible on all workspaces.
**Note:** This API always returns false on Windows.
#### `win.setIgnoreMouseEvents(ignore)`
#### `win.setIgnoreMouseEvents(ignore[, options])`
* `ignore` Boolean
* `options` Object (optional)
* `forward` Boolean (optional) _Windows_ - If true, forwards mouse move
messages to Chromium, enabling mouse related events such as `mouseleave`.
Only used when `ignore` is true. If `ignore` is false, forwarding is always
disabled regardless of this value.
Makes the window ignore all mouse events.

View file

@ -103,6 +103,27 @@ let win = new BrowserWindow()
win.setIgnoreMouseEvents(true)
```
### Forwarding
Ignoring mouse messages makes the web page oblivious to mouse movement, meaning
that mouse movement events will not be emitted. On Windows operating systems an
optional parameter can be used to forward mouse move messages to the web page,
allowing events such as `mouseleave` to be emitted:
```javascript
let win = require('electron').remote.getCurrentWindow()
let el = document.getElementById('clickThroughElement')
el.addEventListener('mouseenter', () => {
win.setIgnoreMouseEvents(true, {forward: true})
})
el.addEventListener('mouseleave', () => {
win.setIgnoreMouseEvents(false)
})
```
This makes the web page click-through when over `el`, and returns to normal
outside it.
## Draggable region
By default, the frameless window is non-draggable. Apps need to specify