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

Keyboard and focus issues with WebView2 and WinForms on .NET preview 7 #1703

Open
noseratio opened this issue Sep 1, 2021 · 7 comments
Open
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@noseratio
Copy link

noseratio commented Sep 1, 2021

Description

I've tried the latest WebView2 (SDK v1.0.955-prerelease, runtime v92.0.902.84) with Windows Forms on .NET v6.0.100-preview.7. I'm seeing a lot of improvements, but I still could spot the following issues:

  • Alt+Space for system menu doesn't work when the focus is inside WebView2. OTOH, Alt+F4 does work as expected, I believe it didn't in early releases 👍.
  • App-specific WinForms accelerators (e.g., Alt+X) still don't work when the focus is inside WebView2. They do when the focus is inside a native control like TextBox.
    Related WPF issue: WPF Key Forwarding from WebView2 to Host application? #468.
  • Pressing and releasing Alt inside WebView2 activates WinForms menu, but the focus remains inside WebView2:

Version
WebView2 SDK v1.0.955-prerelease
WebView2 runtime v92.0.902.84
.NET v6.0.100-preview.7
Windows 10 v19043.1165

Repro Steps

AB#34280866

@noseratio noseratio added the bug Something isn't working label Sep 1, 2021
@noseratio noseratio changed the title Keyboard a focus issues with WebView2 and WinForms on .NET preview 7 Keyboard and focus issues with WebView2 and WinForms on .NET preview 7 Sep 1, 2021
@noseratio
Copy link
Author

TBH, at this stage I feel like the best path for hosting WebView2 is to implement a custom wrapper on top of CoreWebView2 and CoreWebView2Controller.

That would give me direct access to important VW2 integration APIs like AcceleratorKeyPressed, GotFocus, LostFocus, MoveFocusRequested etc.

@champnic
Copy link
Member

Hey @noseratio - thanks for the bug reports! I believe these are mostly tracked in other issues, but I've added this to our scenario we have for tracking keyboarding issues and improving the experience here. We know this is currently a bad pain-point for devs using our .NET controls and have this as a high-priority scenario on our backlog. Thanks!

@noseratio
Copy link
Author

Hi @champnic, thanks for putting it on track. FWIW, the current keyboard/focus behavior is a lot better than that of BlazorWebView, at least in its current iteration where it's practically unusable: dotnet/maui#2341.

I keep saying it... I believe would be beneficial for both Microsoft and the WebView2 dev community if (at least) the .NET wrappers for WebView2 were made open-source.

Some folks, me included, have been dealing with browser control integration issues since the early days of IE ActiveX-based WebBrowser wrappers in .NET. We might help fixing a bug or adding a feature. For example, BlazorWebView again, like this kind of things.

@zhuhaichao518
Copy link
Contributor

zhuhaichao518 commented Jan 30, 2023

Hi, @noseratio! We have released a new feature in the recent release(109). Focus and Inputs will be on native apps in this mode. You can enable this mode by enabling the feature flag ("--enable-features=msWebView2BrowserHitTransparent") in
CoreWebView2CreationProperties.AdditionalBrowserArguments or
CoreWebView2EnvironmentOptions.AdditionalBrowserArguments.
I think enabling this feature will make Alt+X work(still some work to make Alt+Space work).
Because this is a big change, there may be new bugs in this new feature. Please notify us if you find new issue related to the new feature.

@noseratio
Copy link
Author

@zhuhaichao518 thank you - well done, good to see some progress! I'll give this new feature a try and will report what I'll find.

@Optimierungswerfer
Copy link

What is the current state of this? It appears that there is still no official documentation about this feature. It isn't even listed in here.

@champnic
Copy link
Member

We now have a ControllerOptions API for enabling this, instead of the feature flag:
https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2controlleroptions.allowhostinputprocessing?view=webview2-dotnet-1.0.2730-prerelease

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

4 participants