Skip to content

Commit

Permalink
Moved capture into Opened/Closed events for Popup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Taylor committed Feb 14, 2017
1 parent ee5fd34 commit cf0ad7a
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions CefSharp.Wpf/ChromiumWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ protected virtual void Dispose(bool isDisposing)

if(popup != null)
{
popup.MouseEnter -= PopupMouseEnter;
popup.MouseLeave -= PopupMouseLeave;
popup.Opened -= PopupOpened;
popup.Closed -= PopupClosed;
popup = null;
}

Expand Down Expand Up @@ -1633,8 +1633,8 @@ private Popup CreatePopup()
Placement = PlacementMode.Absolute,
};

newPopup.MouseEnter += PopupMouseEnter;
newPopup.MouseLeave += PopupMouseLeave;
newPopup.Opened += PopupOpened;
newPopup.Closed += PopupClosed;

return newPopup;
}
Expand Down Expand Up @@ -1898,24 +1898,26 @@ protected override void OnMouseWheel(MouseWheelEventArgs e)
}

/// <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);
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>
Expand All @@ -1928,7 +1930,6 @@ protected override void OnMouseDown(MouseButtonEventArgs e)
{
Focus();
OnMouseButton(e);
Mouse.Capture(this);
}

/// <summary>
Expand All @@ -1938,7 +1939,6 @@ protected override void OnMouseDown(MouseButtonEventArgs e)
protected override void OnMouseUp(MouseButtonEventArgs e)
{
OnMouseButton(e);
Mouse.Capture(null);
}

/// <summary>
Expand Down

0 comments on commit cf0ad7a

Please sign in to comment.