MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
440 stars 51 forks source link

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

Open noseratio opened 3 years ago

noseratio commented 3 years ago

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:

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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: https://github.com/dotnet/maui/issues/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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 month ago

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 commented 1 month ago

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