Skip to content

Commit 99c7984

Browse files
committed
WPF - Fix OnMouseLeave in ChromiumWebBrowserWithMouseCapture
- Only send a mouse move on leave - Update SimpleMainWindow.xaml to use ChromiumWebBrowserWithMouseCapture for testing purposes
1 parent 08b6c05 commit 99c7984

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

CefSharp.Wpf.Example/SimpleMainWindow.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
<Window x:Class="CefSharp.Wpf.Example.SimpleMainWindow"
1+
<Window x:Class="CefSharp.Wpf.Example.SimpleMainWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
5+
xmlns:experimental="clr-namespace:CefSharp.Wpf.Experimental;assembly=CefSharp.Wpf"
56
Title="SimpleMainWindow" WindowState="Maximized">
67
<Grid>
78
<Grid.RowDefinitions>
89
<RowDefinition />
910
<RowDefinition Height="Auto" />
1011
</Grid.RowDefinitions>
11-
<wpf:ChromiumWebBrowser Grid.Row="0"
12+
<experimental:ChromiumWebBrowserWithMouseCapture Grid.Row="0"
1213
x:Name="Browser"
1314
Address="http://www.google.com" />
1415
<StatusBar Grid.Row="1">

CefSharp.Wpf/Experimental/ChromiumWebBrowserWithMouseCapture.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
using System;
66
using System.Windows.Input;
7+
using CefSharp.Internals;
8+
using CefSharp.Wpf.Internals;
79

810
namespace CefSharp.Wpf.Experimental
911
{
@@ -46,5 +48,21 @@ protected override void OnMouseUp(MouseButtonEventArgs e)
4648
}
4749
}
4850

51+
protected override void OnMouseLeave(MouseEventArgs e)
52+
{
53+
if (!e.Handled && !IsDisposed)
54+
{
55+
var modifiers = e.GetModifiers();
56+
var point = e.GetPosition(this);
57+
58+
var host = this.GetBrowserHost();
59+
if (host != null && !host.IsDisposed)
60+
{
61+
host.SendMouseMoveEvent((int)point.X, (int)point.Y, true, modifiers);
62+
}
63+
64+
((IWebBrowserInternal)this).SetTooltipText(null);
65+
}
66+
}
4967
}
5068
}

0 commit comments

Comments
 (0)