Webview is not capturing mouse events like click


#1

Hi, I’m using Electron 1.4.8 on Windows 10. Mouse events in WebView don’t work.
I’m trying to register click event using jQuery:

webview.on('click', function() {
    console.log("do something")
}

or

webview.click(function() {
    console.log("do something")
}

I tried also standard events:

webview.addEventListener('click', function() {
    console.log("do something")
}

and it doesn’t work.


#2

I don’t believe you can add an event listener on the webview itself but what you can do is add that event on the webview’s body element.


#3

Ok but when I use $(document).click() event, this event is not working on webview. Is there a workaround for this?


#4

The problem is that $(document).click() is a event called on the parent view and in this case on the webview container.
Have you tried $('body').click() inside your webview’s script? Not the paarent script.
Please, append some code sample so I can see exactly what you are trying to do and eventually provide a better answer.
Cheers.


#5

Ok thank you :). Problem has been solved


#6

Glad I could help :slight_smile:


#7

Hey @Sential How did you solve this? I am using latest electron app and I am trying to get click event happening inside a webview. Any help would be appreciated. Thanks!