-
Notifications
You must be signed in to change notification settings - Fork 621
Open
Labels
area/SkiaSharpIssues that relate to the C# binding of SkiaSharp.Issues that relate to the C# binding of SkiaSharp.os/Windows-ClassicIssues running on Microsoft Windows using Win32 APIs (Windows.Forms or WPF)Issues running on Microsoft Windows using Win32 APIs (Windows.Forms or WPF)type/enhancement
Description
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 handlesPaintSurface, no input events - Windows Forms
SKControl/SKGLControl(source/SkiaSharp.Views/SkiaSharp.Views.WindowsForms/) — only handlesPaintSurface, no input events - Neither platform has any
SKTouchHandleror touch event infrastructure
Note: This requires building touch handler infrastructure first (not just wheel support). Consider implementing the full
SKTouchEventArgspipeline 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 upDelta < 0= backward (toward user) = scroll down- Already matches v120 convention — passthrough
Official Documentation
- MouseWheelEventArgs.Delta — "the amount the mouse wheel has changed"
- Mouse.MouseWheelDeltaForOneLine — the constant 120
- UIElement.MouseWheel Event — WPF event to subscribe to
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
- MouseEventArgs.Delta (WinForms) — "a signed count of the number of detents the wheel has rotated, multiplied by the WHEEL_DELTA constant"
- Control.MouseWheel Event — WinForms event to subscribe to
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 neededImplementation Notes
- This is a larger effort — WPF and WinForms views have NO touch handler infrastructure today. Adding wheel support requires:
- Creating
SKTouchHandlerequivalent for WPF/WinForms (or adding events to existing view classes) - Wiring up
MouseWheelevent alongside other input events (MouseDown, MouseMove, MouseUp, etc.) - Exposing
Touchevent andEnableTouchEventsproperty onSKElement/SKControl
- Creating
- Consider following the MAUI pattern: separate
SKTouchHandlerclass that can be attached to the view - The MAUI Windows handler (
Platform/Windows/SKTouchHandler.cs) is a good reference, but uses WinUIPointerRoutedEventArgswhich differs from WPF/WinForms APIs - Priority is lower than MAUI platforms since WPF/WinForms views are less commonly used with touch/input
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/SkiaSharpIssues that relate to the C# binding of SkiaSharp.Issues that relate to the C# binding of SkiaSharp.os/Windows-ClassicIssues running on Microsoft Windows using Win32 APIs (Windows.Forms or WPF)Issues running on Microsoft Windows using Win32 APIs (Windows.Forms or WPF)type/enhancement
Type
Projects
Status
New