-
Notifications
You must be signed in to change notification settings - Fork 616
Description
Description
On Mac Catalyst, SKCanvasView with EnableTouchEvents = true does not deliver mouse wheel or trackpad scroll events. The Touch event never fires with ActionType = SKTouchAction.WheelChanged, even though the SKTouchAction enum includes WheelChanged and SKTouchEventArgs has a WheelDelta property.
Expected Behavior
When the user scrolls with the mouse wheel or two-finger trackpad gesture over the SKCanvasView, the Touch event should fire with:
ActionType = SKTouchAction.WheelChangedWheelDeltaset to the scroll amountLocationset to the cursor position
Actual Behavior
No WheelChanged events are delivered. Scrolling with mouse wheel or trackpad two-finger scroll over the canvas produces no touch events at all.
Root Cause Analysis
On Mac Catalyst (UIKit), scroll wheel events are delivered via UIScrollView integration or by overriding scrollWheel(with:) on the UIView. The standard touch handling (touchesBegan/touchesMoved/touchesEnded) does not capture scroll wheel input.
Suggested Fix
In the Mac Catalyst platform handler for SKCanvasView, override ScrollWheel:
// In the native Mac Catalyst view for SKCanvasView
#if MACCATALYST
public override void ScrollWheel(UIEvent uiEvent)
{
base.ScrollWheel(uiEvent);
// UIEvent on Mac Catalyst provides scroll delta through the underlying CGEvent
// For Mac Catalyst 13.4+, we can use UIScrollEvent (subclass of UIEvent)
if (uiEvent is not null)
{
var allTouches = uiEvent.AllTouches;
// Alternative: use the scrolling delta from the event
// On Mac Catalyst, you can access scroll data via the native event
var location = /* get cursor location */;
var wheelDelta = /* extract from event */;
var args = new SKTouchEventArgs(
id: -1,
type: SKTouchAction.WheelChanged,
mouse: SKMouseButton.Unknown,
device: SKTouchDeviceType.Mouse,
position: new SKPoint((float)location.X, (float)location.Y),
inContact: false,
wheelDelta: wheelDelta,
pressure: 0);
OnTouch(args);
}
}
#endifAlternatively, for Mac Catalyst 15.0+, a UIPanGestureRecognizer with allowedScrollTypesMask set to .all can capture trackpad scroll gestures and convert them to wheel events.
Reproduction Steps
- Create a MAUI app targeting
net9.0-maccatalyst - Add an
SKCanvasViewwithEnableTouchEvents="True" - Subscribe to the
Touchevent and log all events (includingActionTypeandWheelDelta) - Run on macOS
- Scroll with mouse wheel or two-finger trackpad gesture over the canvas
- Observe: no
WheelChangedevents are logged,WheelDeltais always 0
Environment
- SkiaSharp: 3.119.1
- SkiaSharp.Views.Maui.Controls: 3.119.1
- .NET: 9.0
- macOS (Mac Catalyst)
Related
- [Mac Catalyst] Mouse hover (non-contact move) events not delivered by SKCanvasView #3523 (Mouse hover events also not delivered on Mac Catalyst)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status