-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add PointerWheelChanged to PointerGestureRecognizer #16130
Comments
This would be amazing. Alternatively, any guidance on how to best hook this in MAUI would be appreciated as well! |
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process. |
+1 |
Hi @beto-rodriguez, I think found a solution to that issue. For detection when the mouse wheel is fired in Windows desktop devices, you could use an MAUI handler for that. I attached an example source below, I hope it helps.
XAML
|
@RamzesMWDN Thanks! that works! |
#16130 (comment) makes it work on Windows, now to make it work on MacOS is tricky, I am using the gestures provided on MAUI and work nice on IOS, but the problem is that they are not fired when we use a magic mouse on MacOS. I was able to make it work using the UIPanGestureRecognizer, but I am not sure if this is the recommended way. My code zooms in/out when:
I was not able to achieve that with the Gestures provided in MAUI. #if MACCATALYST
private void OnHandlerChanged(object? sender, EventArgs e)
{
var view = (Microsoft.Maui.Platform.ContentView?)canvas.Handler?.PlatformView
?? throw new Exception("Unable to cast to ContentView");
view.AddGestureRecognizer(new UIPanGestureRecognizer(GetOnPan(view))
{
AllowedScrollTypesMask = UIScrollTypeMask.Discrete | UIScrollTypeMask.Continuous,
MinimumNumberOfTouches = 0
});
}
private CoreGraphics.CGPoint? _last;
private Action<UIPanGestureRecognizer> GetOnPan(UIView view)
{
return (UIPanGestureRecognizer e) =>
{
var l = e.LocationInView(view);
_last ??= l;
var delta = _last.Value.Y - l.Y;
var isZoom = e.NumberOfTouches == 0;
if (e.State == UIGestureRecognizerState.Ended || !isZoom || delta == 0) return;
var c = (CartesianChart<SkiaSharpDrawingContext>)CoreChart;
c.Zoom(new(l.X, l.Y), delta > 0 ? ZoomDirection.ZoomIn : ZoomDirection.ZoomOut);
_last = l;
};
}
#endif Even this seems to work properly, I am not sure if this is the way to handle this scenario. I practically forced this, I just tested and noticed that Can I rely on this code? could this change in a future? |
I would greatly appreciate this feature being implemented into a future release of MAUI. It definintely feels like its absent from the GestureRecgonizer lineup |
Description
I think it is necessary to be able to detect when the mouse wheel is fired in desktop devices. In my case I want to fire the Zoom functionality of a chart control when the mouse wheel moves, I think this is currently not possible.
Public API Changes
The text was updated successfully, but these errors were encountered: