mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 11:42:36 +00:00
Merge branch 'mouse-capture-crash' of https://github.com/taylorjonl/CefSharp
This commit is contained in:
@@ -470,8 +470,8 @@ namespace CefSharp.Wpf
|
||||
|
||||
if(popup != null)
|
||||
{
|
||||
popup.MouseEnter -= PopupMouseEnter;
|
||||
popup.MouseLeave -= PopupMouseLeave;
|
||||
popup.Opened -= PopupOpened;
|
||||
popup.Closed -= PopupClosed;
|
||||
popup = null;
|
||||
}
|
||||
|
||||
@@ -1639,8 +1639,8 @@ namespace CefSharp.Wpf
|
||||
Placement = PlacementMode.Absolute,
|
||||
};
|
||||
|
||||
newPopup.MouseEnter += PopupMouseEnter;
|
||||
newPopup.MouseLeave += PopupMouseLeave;
|
||||
newPopup.Opened += PopupOpened;
|
||||
newPopup.Closed += PopupClosed;
|
||||
|
||||
return newPopup;
|
||||
}
|
||||
@@ -1904,24 +1904,29 @@ namespace CefSharp.Wpf
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the mouse cursor entering the pop-up.
|
||||
/// Captures the mouse when the popup is opened.
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||||
private void PopupMouseEnter(object sender, MouseEventArgs e)
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
private void PopupOpened(object sender, EventArgs e)
|
||||
{
|
||||
Focus();
|
||||
Mouse.Capture(this, CaptureMode.Element);
|
||||
if (Mouse.Captured != this)
|
||||
{
|
||||
Mouse.Capture(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the mouse cursor exiting the pop-up.
|
||||
/// Releases mouse capture when the popup is closed.
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||||
private void PopupMouseLeave(object sender, MouseEventArgs e)
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
private void PopupClosed(object sender, EventArgs e)
|
||||
{
|
||||
Mouse.Capture(this, CaptureMode.None);
|
||||
if (Mouse.Captured == this)
|
||||
{
|
||||
Mouse.Capture(null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1934,7 +1939,6 @@ namespace CefSharp.Wpf
|
||||
{
|
||||
Focus();
|
||||
OnMouseButton(e);
|
||||
Mouse.Capture(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1944,7 +1948,6 @@ namespace CefSharp.Wpf
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e)
|
||||
{
|
||||
OnMouseButton(e);
|
||||
Mouse.Capture(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user