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
- Create a MAUI app targeting
net9.0-maccatalyst
- Add an
SKCanvasView with EnableTouchEvents="True"
- Subscribe to the
Touch event and log all events (including ActionType and WheelDelta)
- Run on macOS
- Scroll with mouse wheel or two-finger trackpad gesture over the canvas
- 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
Description
On Mac Catalyst,
SKCanvasViewwithEnableTouchEvents = truedoes not deliver mouse wheel or trackpad scroll events. TheTouchevent never fires withActionType = SKTouchAction.WheelChanged, even though theSKTouchActionenum includesWheelChangedandSKTouchEventArgshas aWheelDeltaproperty.Expected Behavior
When the user scrolls with the mouse wheel or two-finger trackpad gesture over the
SKCanvasView, theTouchevent should fire with:ActionType = SKTouchAction.WheelChangedWheelDeltaset to the scroll amountLocationset to the cursor positionActual Behavior
No
WheelChangedevents 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
UIScrollViewintegration or by overridingscrollWheel(with:)on theUIView. The standard touch handling (touchesBegan/touchesMoved/touchesEnded) does not capture scroll wheel input.Suggested Fix
In the Mac Catalyst platform handler for
SKCanvasView, overrideScrollWheel:Alternatively, for Mac Catalyst 15.0+, a
UIPanGestureRecognizerwithallowedScrollTypesMaskset to.allcan capture trackpad scroll gestures and convert them to wheel events.Reproduction Steps
net9.0-maccatalystSKCanvasViewwithEnableTouchEvents="True"Touchevent and log all events (includingActionTypeandWheelDelta)WheelChangedevents are logged,WheelDeltais always 0Environment
Related