Skip to content
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

Can transparent page support hit testing? #1351

Closed
panxn opened this issue Jun 3, 2021 · 3 comments
Closed

Can transparent page support hit testing? #1351

panxn opened this issue Jun 3, 2021 · 3 comments
Assignees
Labels
feature request feature request

Comments

@panxn
Copy link

panxn commented Jun 3, 2021

I hope to use transparent(no background) webview2 page as UI layer over d3d layer, just like head up display in video game, mouse events are handled by UI layer if there is html element (e.g. button), otherwise passed to d3d layer.

I'm using function ICoreWebView2CompositionController::SendMouseInput to forward mouse events, but no way to do hit-testing, so I wonder if webview2 can provide a function or any other approach.

There is a similar request #1004, no progress. I'm afraid it's not easy, it's also very helpful if you can tell me it's impossible, thanks!

@panxn panxn added the feature request feature request label Jun 3, 2021
@champnic
Copy link
Member

champnic commented Jun 11, 2021

Hey @libaracy - As mentioned #1004 will add support for this. In the meantime, if you control the content of the webpage (which it sounds like you do if you're building a HUD-type experience) you could track mouse-events in the javascript which don't hit a button, and then send those back up to the host app. You can add that script to the page itself or through ICoreWebView2::ExecuteScript, and then send the hit-test results to the host app using a host object (ICoreWebView2::AddHostObjectToScript) or web messaging.

@champnic champnic self-assigned this Jun 11, 2021
@panxn
Copy link
Author

panxn commented Jun 17, 2021

Hi @champnic , thanks for your response. Yes, what I want is very close to HUD.
The solution you suggest is what I'm using now, I used to think it's bad for performance. After testing, it's acceptable. However it's not so convenient, it need special handling for popup/focus in webview. Anyway it will be nice if webview2 sdk can provide some function to do it. Thanks!

@champnic
Copy link
Member

Thanks for the feedback. I'll close this issue for now and we'll continue to track using #1004. Thanks!

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

No branches or pull requests

2 participants