Skip to content

Add wheel support to WPF and Windows Forms views with v120 normalization #3539

@mattleibow

Description

@mattleibow

Overview

Add scroll wheel support to SkiaSharp's WPF and Windows Forms views by adding touch handler infrastructure and wiring up MouseWheel events, passing through the native values which are already in the v120 standard (120 = one discrete mouse wheel notch).

Parent issue: #3533

Current State

  • WPF SKElement / SKGLElement (source/SkiaSharp.Views/SkiaSharp.Views.WPF/) — only handles PaintSurface, no input events
  • Windows Forms SKControl / SKGLControl (source/SkiaSharp.Views/SkiaSharp.Views.WindowsForms/) — only handles PaintSurface, no input events
  • Neither platform has any SKTouchHandler or touch event infrastructure

Note: This requires building touch handler infrastructure first (not just wheel support). Consider implementing the full SKTouchEventArgs pipeline for mouse/touch/pen events at the same time.

Platform Details — WPF

Native API

System.Windows.Input.MouseWheelEventArgs.Delta

private void OnMouseWheel(object sender, MouseWheelEventArgs e) {
    int delta = e.Delta;  // ±120 per notch, already v120!
}

Raw Values

Device Delta value Notes
Standard mouse notch ±120 Exactly WHEEL_DELTA
Fast scroll ±240, ±360 Multiple notches per event
High-res mouse ±15, ±30, ±60 Sub-notch values
Precision trackpad ±1 to ±119 Fine-grained

Sign Convention

  • Delta > 0 = forward (away from user) = scroll up
  • Delta < 0 = backward (toward user) = scroll down
  • Already matches v120 convention — passthrough

Official Documentation

Platform Details — Windows Forms

Native API

System.Windows.Forms.MouseEventArgs.Delta

private void OnMouseWheel(object sender, MouseEventArgs e) {
    int delta = e.Delta;  // ±120 per notch, already v120!
}

Raw Values

Same as WPF — uses the same underlying WM_MOUSEWHEEL Windows message.

Official Documentation

Normalization Logic

// Both WPF and WinForms: passthrough — already v120
int wheelDelta = e.Delta;
// Mouse notch up → 120
// Mouse notch down → -120
// High-res mouse → sub-120 values
// No conversion needed

Implementation Notes

  • This is a larger effort — WPF and WinForms views have NO touch handler infrastructure today. Adding wheel support requires:
    1. Creating SKTouchHandler equivalent for WPF/WinForms (or adding events to existing view classes)
    2. Wiring up MouseWheel event alongside other input events (MouseDown, MouseMove, MouseUp, etc.)
    3. Exposing Touch event and EnableTouchEvents property on SKElement/SKControl
  • Consider following the MAUI pattern: separate SKTouchHandler class that can be attached to the view
  • The MAUI Windows handler (Platform/Windows/SKTouchHandler.cs) is a good reference, but uses WinUI PointerRoutedEventArgs which differs from WPF/WinForms APIs
  • Priority is lower than MAUI platforms since WPF/WinForms views are less commonly used with touch/input

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/SkiaSharpIssues that relate to the C# binding of SkiaSharp.os/Windows-ClassicIssues running on Microsoft Windows using Win32 APIs (Windows.Forms or WPF)type/enhancement

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions