MicrosoftEdge / MicrosoftEdge/WebView2Feedback
MouseHover and MouseMove events do not work with WebView2
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Description
The MouseHover and MouseMove events do not work with WebView2 in WinForms.
Version
SDK: 0.9.579-prerelease
Runtime: Canary 87.0.635.0 64-bits
Framework: WinForms with dotnet 5.0.100-rc.1.20452.10
OS: Win10 Version 2004 Build 19041.450 64-bits
Repro Steps
Add a MouseHover OR MouseMove event handler (not together) to the WebView2 instance in the *Form.Designer.cs file:
private void InitializeComponent()
{
this._webBrowser = new Microsoft.Web.WebView2.WinForms.WebView2();
this.SuspendLayout();
//
// _webBrowser
//
this._webBrowser.Name = "_webBrowser";
... // Bunch of other properties set
this._webBrowser.MouseHover += new System.EventHandler(this.WebBrowser_MouseHover);
// OR
this._webBrowser.MouseMove += new System.Windows.Forms.MouseEventHandler(this.WebBrowser_MouseMove);
// But do not test them together
...
The event methods are defined like this in the *Form.cs file:
private void WebBrowser_MouseHover(object sender, EventArgs e)
{
Close();
}
private void WebBrowser_MouseMove(object sender, MouseEventArgs e)
{
Close();
}
It seems the WebView2 instance is able to detect mouse hover, but only on the first miliseconds while the window is loading. After that, once the webpage starts loading, there is no way to exit the app except if I kill it (or manually add a handler to detect the Esc key and exit the app).
Additional context
I tried adding the event handlers directly in my Form instance, but it seems Edge eats the mouse events and prevents my app from reading them.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue from the handlers wired in Form.Designer.cs and implemented in Form.cs, using the reported WinForms and WebView2 versions as context. Trace whether MouseHover and MouseMove reach the handlers after page loading, and consider the issue done when the relevant event fires reliably or the supported limitation is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100