Skip to content

Webview on transparent WPF regions does not hittest. #997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Skarnivorous opened this issue Feb 26, 2021 · 8 comments
Open

Webview on transparent WPF regions does not hittest. #997

Skarnivorous opened this issue Feb 26, 2021 · 8 comments
Labels
feature request feature request tracked We are tracking this work internally.

Comments

@Skarnivorous
Copy link

Skarnivorous commented Feb 26, 2021

Description
When WPF window has Allow Transparency and no style (completely transparent window).
And WebView2 is on window region where no other controls are visible (i.e. Panel hosting WebView2 are background transparent / opacity 0).
And WebView2 content is visible (though it may have opacity).
Clicks on WebView2 will pass through WebView2, not trigger webview2 content events, and activate desktop UI beneath the window.

Expectation would be that the WPF hit test takes into account WebView2's visible painted areas.
Ideal would also treat non-painted areas as pass-through.

Version
SDK: 1.0.790-prerelease
Runtime: Version 90.0.809.0
Framework: WPF, C#, XAML
OS: Windows 10 Pro Version 20H2 OS build 19042.804 Windows Feature Experience Pack 120.2212.551.0

Additional context
With the new DefaultBackgroundColor allowing transparency I have successfully rendered WebView2 content in a transparent window with alpha blending/composition on the desktop. The bug above however means that there can be no interaction with the content as the entire control is not hittested even for the areas of the control which are visible.

Re-enabling window background, or having other wpf controls visible behind or in-front of the webview2 will suddenly make the webview2 receive hittest in the regions where the other controls overlap.

AB#31911566

@Skarnivorous Skarnivorous added the bug Something isn't working label Feb 26, 2021
@darbid
Copy link

darbid commented Feb 26, 2021

Can you add an image of what you are talking about? Unfortunately your text is indicating something that is impossible for the webview2 as it is not a true wpf control but a wrapped winforms control and thus allows transparency in wpf will effect the webview2

@Skarnivorous
Copy link
Author

I have linked a screen video to demonstrate. In the video the red box is the webview2 and the clock is a normal image control. You can see that when I click a region in the webview2 that overlaps the clock, the webview2 will receive the click event. However when I click a region in the webview2 that is only overlaying the desktop, the click will pass straight through. I believe the webview2 should still receive the hittest / mouse event as it is still visible. All WPF layer/visual tree type calls also ignore the webview2 in those areas. I would expect if the webview2 has 100% transparency in some region, then it should have this correct behaviour of click passthrough.

https://streamable.com/szltec

@Skarnivorous
Copy link
Author

I am hoping this can be realised as possible via native implementation as I have succeeded using a workaround using CapturePreviewAsync running continuously but I imagine this is a slow routine.

@pagoe-msft pagoe-msft added feature request feature request tracked We are tracking this work internally. and removed bug Something isn't working labels Mar 1, 2021
@pagoe-msft
Copy link

@Skarnivorous

Thanks for submitting this - I've added this item to our backlog.

@Blightbuster
Copy link

I am hoping this can be realised as possible via native implementation as I have succeeded using a workaround using CapturePreviewAsync running continuously but I imagine this is a slow routine.

Would you mind sharing your workaround implementation? I assume you overwrote the HitTestCore method of the WPF WebView2 contol?

@Skarnivorous
Copy link
Author

Skarnivorous commented Jan 6, 2023 via email

@xu-ms
Copy link

xu-ms commented Mar 31, 2023

@Skarnivorous
I try to reproduce your scenario, I've also created an image and WebView control and set webView2Control.DefaultBackgroundColor = System.Drawing.Color.Transparent. It seems that when I click on the transparent area, it is still responded to by the WebView, and the text can be selected. Perhaps my understanding is incorrect; can you please explain further?
Animation

@Skarnivorous
Copy link
Author

Skarnivorous commented Mar 31, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request feature request tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

6 participants