nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

Events from webview since 0.29.3

Open kucix opened this issue 6 years ago • 6 comments

Hi, 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

kucix avatar May 14 '18 07:05 kucix

I can reproduce this issue on Linux/Windows with nwjs-sdk-v0.30.4. It works fine on v0.29.2.

Christywl avatar May 14 '18 08:05 Christywl

And what about this bug? Many versions are already out and the bug is still not fixed. We can not update our app.

kucix avatar Aug 17 '18 11:08 kucix

Will see this soon. Thanks for your patience.

rogerwang avatar Aug 18 '18 01:08 rogerwang

we need this bug fixed ASAP too. thanks.

zahimich avatar Aug 19 '18 06:08 zahimich

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.

rogerwang avatar Aug 19 '18 15:08 rogerwang

Is this "contextmenu" event a wontfix ?

gazhay avatar Apr 02 '22 14:04 gazhay