-
Notifications
You must be signed in to change notification settings - Fork 54
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
WebView2 in WPF ScrollViewer causes arrow, home, end keys to not work in INPUT elements #2052
Comments
Thanks for the bug report @GCymbala - I've added it to our backlog to take a look! |
I'm having this issue as well. Is a blocker for me, as I'm trying to embed a WYSIWYG editor in a WPF-app, and arrow navigation is impossible, since the WebView2 won't respond to them if placed in a scrollviewer (which is neccessary because I have 5 editors stacked vertically) |
Any progress on this? I'm having the same issue! |
Any solutions or workarounds for this problem? |
facing the same problem. want to implement quill editor with wv2 control in my wpf app... arrow key navigation and therefore keyboard selection with shift+arrow keys is not working at all. |
Here is a possible solution, which is not a good one from any perspective, but for my application it does the job: override OnPreviewKeyDown in WebView2, do the analysis ("should I pass that exact key to the control?" and, if not, just omit call to base.OnPreviewKeyDown() altogether. This will prevent internal input event system from working and will isolate all inputs inside the browser itself. Problem statement:If WebView2 is hosted inside ScrollViewer or ListBox, some key combinations won't work, e.g. PageUp/PageDown or Control+A (with ListBox). Why?This is due to how input system works in WebView2 - it tries to simulate WPF events pipeline (with tunneling/bubbling) and relies on the fact that event should not be handled by anyone in the chain for the input to be processed by the browser. From the docs of WebView2:
Pipeline works like this:
2') There is a flag, called _browserHitTransparent, which will omit that subscription altogether, "fixing" the bug, but you will lose all control over keys pressed in the browser
Unfortunately, this does not work very well with RoutedUICommands and bubbling in WPF. For example, both ScrollViewer(e.g. PageUp/Down) and ListBox(Ctrl+A) are registering a bunch of input gestures and intercept keypresses (marking them as Handled whenever they catch them and they can process them). At this point you have two options:
|
Our application is face the same problem too, is there any update of the issue? The team of WV2 is response and solve problems so slowly!!! |
Okay guys. Finally found a solution to the arrows key problem. It has to do with the ScrollViewer in combination with WebView2. This answer on StackOverflow was the solution. You need to make a new ScrollViewer that inherits from the original and then override the OnKeyDown and OnPreviewKeyDown events as follows:
Use this ScrollViewer in your view instead of the original. The arrow keys will start working now. Another strategy is by overriding the OnPreviewKeyDown for WebView2 and using the inherited class:
|
Description
When a WebView2 control is contained within a
<ScrollViewer>
control, input text boxes displayed in the WebView2 no longer respond correctly to arrow, Home and End keysVersion
SDK: Mircorosft.Web.WebView2 1.0.1054.31
Runtime: Microsoft Edge WebView2 Runtime 96.0.1054.62
Framework: WPF
.NET Framework: 4.7.2
OS: Win10
Repro Steps
Create a WPF Windows App with one window containing a DockPanel, ScrollViewer, and WebView2:
Once bing.com has loaded, enter some text in the Bing search text input field.
Try to move the cursor within the text input using left, right arrow keys, and Home and End keys.
Expected behavior: Text input cursor moves according to the keys pressed.
Actual behavior: The cursor does not move. It remains at the end of the text.
AB#37648000
The text was updated successfully, but these errors were encountered: