-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WPF: Add support for back and forward mouse buttons #2133
Comments
Could it be possible to disable this feature? Add a boolean to disable these buttons or make the method overriable. |
It would be appreciated if this feature could be enabled/disabled at runtime, as most of the times this behaviour is wanted but sometimes it is not. |
You can already override the behavior, just inherit from ChromiumWebBrowser, override the two methods for mouse up/down and mark them as handled. |
@amaitland That should work indeed, thanks :) Though that does mean that I need to duplicate In short, if you change some things in |
How about setting the eventargs as handled and call the base method? Shouldn't need to duplicate anything |
That means though that To clarify: I still want (most) of the original behavior of |
That was perfectly clear.
For what reason?
|
I'll add the code of what I have thought of, hopefully you can see where I went wrong with this. I don't intend to use this in production as it is way too hacky. (I also haven't tested this code yet)
I could have gotten it to work in a reasonably nice way if |
You appear to be overthinking things, try. protected override void OnMouseDown(MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.XButton1 || e.ChangedButton == MouseButton.XButton1)
{
e.Handled = true;
}
base.OnMouseDown(e);
} |
That actually seems to be the solution I was looking for :) Thanks a lot, it is simple and effective. |
This is what we had to do to prevent navigation: public class CustomChromiumWebBrowser : ChromiumWebBrowser
{
protected override void OnMouseDown(MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.XButton1 || e.ChangedButton == MouseButton.XButton2)
{
e.Handled = true;
}
base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.XButton1 || e.ChangedButton == MouseButton.XButton2)
{
e.Handled = true;
}
base.OnMouseUp(e);
}
} |
The WPF browser currently ignores XButton1 and XButton2.
These are used to navigate forward and backwards in Chrome, and should probably do so in CefSharp as well
CefSharp/CefSharp.Wpf/ChromiumWebBrowser.cs
Lines 2136 to 2140 in 244aab0
The text was updated successfully, but these errors were encountered: