Add example of using mouse forwarding.
This commit is contained in:
parent
814702f5b8
commit
d4bbd7c7ab
2 changed files with 22 additions and 1 deletions
|
@ -224,7 +224,7 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) {
|
||||||
if (forward && !forwarding_mouse_messages_) {
|
if (forward && !forwarding_mouse_messages_) {
|
||||||
forwarding_mouse_messages_ = true;
|
forwarding_mouse_messages_ = true;
|
||||||
forwarding_windows_.insert(this);
|
forwarding_windows_.insert(this);
|
||||||
|
|
||||||
// Subclassing is used to fix some issues when forwarding mouse messages;
|
// Subclassing is used to fix some issues when forwarding mouse messages;
|
||||||
// see comments in |SubclassProc|.
|
// see comments in |SubclassProc|.
|
||||||
SetWindowSubclass(
|
SetWindowSubclass(
|
||||||
|
|
|
@ -103,6 +103,27 @@ let win = new BrowserWindow()
|
||||||
win.setIgnoreMouseEvents(true)
|
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
|
## Draggable region
|
||||||
|
|
||||||
By default, the frameless window is non-draggable. Apps need to specify
|
By default, the frameless window is non-draggable. Apps need to specify
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue