Skip to content

[Mac Catalyst] Mouse wheel / trackpad scroll events not delivered by SKCanvasView #3524

@mattleibow

Description

@mattleibow

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.WheelChanged
  • WheelDelta set to the scroll amount
  • Location set 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);
    }
}
#endif

Alternatively, 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

  1. Create a MAUI app targeting net9.0-maccatalyst
  2. Add an SKCanvasView with EnableTouchEvents="True"
  3. Subscribe to the Touch event and log all events (including ActionType and WheelDelta)
  4. Run on macOS
  5. Scroll with mouse wheel or two-finger trackpad gesture over the canvas
  6. Observe: no WheelChanged events are logged, WheelDelta is always 0

Environment

  • SkiaSharp: 3.119.1
  • SkiaSharp.Views.Maui.Controls: 3.119.1
  • .NET: 9.0
  • macOS (Mac Catalyst)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions