WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

Transparent pages and clickthrough/mouse/keyboard events

Open LiorBanai opened this issue 4 years ago • 23 comments

So I managed to create a transparent Winform (see image below) but when loading a page with other controls behind the WebView Control they are not clickable. In the example below I cannot click on the button.

Is there a property I need to turn on for events (keyboard/mouse) to get to other controls behind the transparent page (the button is just an example)?

image

AB#31913330

LiorBanai avatar Feb 27 '21 08:02 LiorBanai

@LiorBanai,

Unfortunately, this is not supported in WebView2 today. The WebView2 control that is on top is consuming the click event and not the button behind it. I've filed a feature request to add this to our backlog.

pagoe-msft avatar Mar 02 '21 00:03 pagoe-msft

@pagoe-msft , Thanks for the info.

LiorBanai avatar Mar 02 '21 11:03 LiorBanai

I think if you open a second window and set as transparent with controls in it, they will be over the top and also interactable? controls on top In the attached picture, the button (blue control across the bottom) is able to be interacted whilst it is over the WebView content (the cube). This isn't probably ideal and may have complications, but as proof of concept, it does work.

Skarnivorous avatar Mar 02 '21 12:03 Skarnivorous

@LiorBanai can you please elaborate how you made it transparent?

darbid avatar Mar 18 '21 03:03 darbid

@darbid , use the latest preview version and set "DefaultBackgroundColor" to transparent (by code or editor).

webView2Control.DefaultBackgroundColor = Color.Transparent;

You also need the have you page itself transparent of course

LiorBanai avatar Mar 19 '21 16:03 LiorBanai

@LiorBanai If I were you I would override the Webview2 WndProc and list for mouse clicks and then pass them back into WPF.

darbid avatar Mar 19 '21 17:03 darbid

@LiorBanai If I were you I would override the Webview2 WndProc and list for mouse clicks and then pass them back into WPF.

The problem is that this need to be done only on the transparent part of the page. Not all the page area are transparent

LiorBanai avatar Mar 19 '21 17:03 LiorBanai

Hi, do you have plan to implement this feature? I have similar requirement: A transparent webview2 window over directx window, just like head up display in video game. Mouse events should pass to directx window if there is no html element.

panxn avatar May 07 '21 10:05 panxn

@pagoe-msft any update of this? or expected date?

LiorBanai avatar Aug 02 '21 08:08 LiorBanai

Same porblem here, what works with embedded IE did not work with WebView2 :( Please, could you fix that urgent?

emj-sap avatar Feb 10 '22 11:02 emj-sap

Is there any update on this? We have a feature depending on transparency and we cannot switch to WebView2 because of this issue.

efecan-yilmaz avatar Feb 10 '22 13:02 efecan-yilmaz

Hi guys, this transparency functionality is a total blocker for us switching to WebView2. Can you comment on this and give an estimate? Thank you!

markpapazyan avatar Feb 10 '22 15:02 markpapazyan

In our scenario, we create a transparent window (using SetLayeredWindowAttributes), and create browser control inside that, where ever browser has content, it's clickable, at remaining place background app is clickable (typical scenario of showing bubble help for any application). in Webview2 Browser content part is not clickable, it always pass through to background application. like in attached screenshot (transparent window with both MSHTML & Webview2 on top of calculator) left side browser button got clicked(MSHTML), but right side Webview2 isn't clickable.

EdgeIEDifference

hemantkrajput avatar Feb 11 '22 03:02 hemantkrajput

Hi Colleagues, we really need this fix.

zigel avatar Feb 14 '22 09:02 zigel

Hello, same here, any news? When I click on the window, Webview2 get the main focus. And stop the propagation of keys to the WindowProc of the parent window (win32). It is a problem.

gaetandezeiraud avatar Apr 07 '22 20:04 gaetandezeiraud

👋 @champnic is this still being tracked?

ItsCubeTime avatar Feb 03 '23 21:02 ItsCubeTime

Hey @ItsCubeTime - Yes this is still being tracked, but is lower priority for us. May I ask what your scenario is that you need this feature? It's possible we have an existing workaround or other in the works. For example, we are in the designing phase of fixing the WPF airspace issue (#286) if that is the underlying concern.

champnic avatar Feb 03 '23 22:02 champnic

@champnic

Thanks, the pywebview issue linked right above my message led me here, pywebview can be seen as a more lightweight crossplatform Electron alternative for Python. As commented by its maintainer, Pywebview inherits this issue on the Windows platform & is unique to WebView2.

Im using pywebview to develop a small productivity app & text editor for people working in the medical field to more effectively be able to handle & write journals for there patients.

I was looking to pretty up the borders of my window a bit to make my app a little more visually unique (add rounded borders and a shadow effect to a frameless window via html/css to be precise), which isn't particularly critical. Coming from an artistic background though, being able to have full control over the look of my window without loosing any window functionality would be a nice to have and enable me to get more visually appealing results.

I could also see applications like screen recorders or other apps that require OSD functionality to suffer more heavily from this (issue which I presume to be a) bug.

ItsCubeTime avatar Feb 04 '23 18:02 ItsCubeTime

Hey @ItsCubeTime - Thanks for the info and scenario link. I believe this is generally possible if using the WebView2 Win32 control and changing the attributes of/clipping the HWND parent, but if trying to do rounded corners in this manner with transparency then it does seem blocked by this bug if the WebView2 is on top of other elements that are intended to be clicked.

champnic avatar Feb 06 '23 19:02 champnic

My problem is that when the Webview2 control is made transparent, all clicks, regardless of whether they occur in the transparent or opaque part of the page, simply fall through to the window below, without being captured by webview2. Is this the same problem other people are experiencing?

Likewise with mouse hover events.

With the old IE browser control, if my click/hovering is over the opaque portion of the page, those events will be intercepted by the browser control. If they are over transparent portions, they will fall through to the window below -- as desired.

yg-i avatar Dec 07 '23 21:12 yg-i

Attempted with following combination:

  • Win32 app with webview2
  • Webview2 content is rendered via Windows Composition
  • Made window transparent WS_EX_TRANSPARENT
  • Added partial transparent webpage

Above changes were done webview2 wincomp Win32 sample app.

Following was the observation:

  • When a other application window is present in background, mouse messages were getting sent to that Window
  • When desktop was present, mouse messages were not working on desktop

Using Windows Composition is supposed to work as there is no Webview2's HWND and rendering is done in the Win32 app itself, any ideas what's going on here?

venki-thiyag avatar Dec 04 '24 06:12 venki-thiyag

mark

tangfengray avatar May 14 '25 12:05 tangfengray

Checking in on this issue - any progress made? This is a deal-breaker for me, personally.

switz avatar Oct 24 '25 05:10 switz