Events from webview since 0.29.3
See original GitHub issueHi, in version from version 0.29.3 events from webview stopped bubbling to main page. eg. mouse event contextmenu In version 0.29.2 event contextmenu bubbles to main page, where i catch it, stop it, read coordinates and show own menu. In version 0.29.3 this is not possible. I can this case simulate with webview.contextmenus.onshow handler, but coordinates are missing, so I don’t know where to show menu. And what about other events, like on keypress (eg catch ctrl+f to show search field for search through webview) I am using nwjs as a simple web browser.
======== TEMPLATE BUG FORM ========
NWJS Version : >= 0.29.3 Operating System : Windows
Expected behavior
Events from page in webview bubbling to main page.
Actual behavior
Events not bubbling
How to reproduce
package.json
{
"name": "name",
"appId": "com.domain.name",
"version": "1.0.0",
"main": "/init.html",
"window": {
"title": "Bug",
"position": "center",
"min_width": 1000,
"min_height": 700
},
"user-agent": "%name/%ver (%osinfo)"
}
init.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="init.js"></script>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
overflow: hidden;
}
#wv {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: block;
}
</style>
</head>
<body>
<webview id="wv" src="https://www.google.com/"></webview>
</body>
</html>
####init.js
var win = nw.Window.get();
win.showDevTools();
win.onDocumentEnd.addListener(function(e){
document.getElementById('wv').addEventListener('contextmenu', function(e){
console.debug(e);
});
});
Version 0.29.2 - after right click is event logged in console with x,y position Version 0.29.3 and above - after right click is nothing logged in console Tested with version 0.30.4
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
In upstream the
webview
tag supports a limited set of events: https://developer.chrome.com/apps/tags/webview . Listening on arbitrary dom events including ‘contextmenu’ is viewed as undocumented usage, which unfortunately breaks when upstream changed the underlying architecture. Now the webview runs in a separate process so the event listener registered in another process would not work since they reside in different web engines.Before we find a solution I suggest injecting a script in the webview and forward the event to your application. Thanks.
Is this “contextmenu” event a wontfix ?