Browse Source

Add example of using mouse forwarding.

Andreas Flöjt 7 years ago
parent
commit
d4bbd7c7ab
2 changed files with 22 additions and 1 deletions
  1. 1 1
      atom/browser/native_window_views_win.cc
  2. 21 0
      docs/api/frameless-window.md

+ 1 - 1
atom/browser/native_window_views_win.cc

@@ -224,7 +224,7 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) {
   if (forward && !forwarding_mouse_messages_) {
     forwarding_mouse_messages_ = true;
     forwarding_windows_.insert(this);
-    
+
     // Subclassing is used to fix some issues when forwarding mouse messages;
     // see comments in |SubclassProc|.
     SetWindowSubclass(

+ 21 - 0
docs/api/frameless-window.md

@@ -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