Skip to content

Commit

Permalink
WPF: Added support for back and forward mouse buttons
Browse files Browse the repository at this point in the history
Resolves cefsharp#2133
  • Loading branch information
merceyz committed Aug 31, 2017
1 parent 244aab0 commit bad729e
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions CefSharp.Wpf/ChromiumWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2133,19 +2133,30 @@ protected override void OnMouseLeave(MouseEventArgs e)
/// <param name="e">The <see cref="MouseButtonEventArgs"/> instance containing the event data.</param>
private void OnMouseButton(MouseButtonEventArgs e)
{
// Cef currently only supports Left, Middle and Right button presses.
if (e.ChangedButton > MouseButton.Right)
{
return;
}

if (browser != null)
{
var modifiers = e.GetModifiers();
var mouseUp = (e.ButtonState == MouseButtonState.Released);
var point = e.GetPosition(this);

browser.GetHost().SendMouseClickEvent((int)point.X, (int)point.Y, (MouseButtonType)e.ChangedButton, mouseUp, e.ClickCount, modifiers);
if (e.ChangedButton == MouseButton.XButton1)
{
if (CanGoBack && mouseUp)
{
this.Back();
}
}
else if (e.ChangedButton == MouseButton.XButton2)
{
if (CanGoForward && mouseUp)
{
this.Forward();
}
}
else
{
browser.GetHost().SendMouseClickEvent((int)point.X, (int)point.Y, (MouseButtonType)e.ChangedButton, mouseUp, e.ClickCount, modifiers);
}

e.Handled = true;
}
Expand Down

0 comments on commit bad729e

Please sign in to comment.