question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Events from webview since 0.29.3

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rogerwangcommented, Aug 19, 2018

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.

0reactions
gazhaycommented, Apr 2, 2022

Is this “contextmenu” event a wontfix ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebView - Android Developers
android:hapticFeedbackEnabled, Boolean that controls whether a view should have haptic feedback enabled for events such as long presses.
Read more >
Xamarin.Forms WebView - Microsoft Learn
Events. WebView raises the following events to help you respond to changes in state: Navigating – event raised when the WebView begins loading ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found