Skip to content

WinUI: Add keyboard modifier detection (#4967)#4970

Merged
swharden merged 4 commits intoScottPlot:mainfrom
diluculo:add-keymodifier-support
Jul 29, 2025
Merged

WinUI: Add keyboard modifier detection (#4967)#4970
swharden merged 4 commits intoScottPlot:mainfrom
diluculo:add-keymodifier-support

Conversation

@diluculo
Copy link
Contributor

Implements UpdateKeyStateFromModifiers helper to detect Ctrl/Shift/Alt states from mouse events, enabling enhanced interactions like Ctrl+MouseWheel zoom.

Also upgrades Windows App SDK to 1.7 and lowers target framework to net8.0-windows10.0.19041.0 due to v1.5 runtime issues in my environment (can be reverted if needed).

Fixes #4967

Additional Notes

For future KeyDown/KeyUp event handling from SKXamlCanvas in WinUIPlot.cs, the CreateRenderTarget() method would need focus-related properties:

private static SKXamlCanvas CreateRenderTarget()
{
   return new SKXamlCanvas
   {
       // ... (existing VerticalAlignment, HorizontalAlignment, Background) ...
       
       IsTabStop = true,                    // Enables the control to receive focus
       AllowFocusOnInteraction = true       // Allows focus on mouse interaction
   };
}

This PR focuses on mouse-based modifier detection using PointerRoutedEventArgs, which doesn't require focus.

diluculo added 2 commits June 11, 2025 11:31
- Supports Ctrl, Shift, Alt, and Windows key detection from PointerEventArgs
- Enables modifier key combinations in WinUI mouse interactions
- Foundation for implementing Ctrl+Click, Shift+Drag functionality
@swharden
Copy link
Member

Thanks @diluculo! I don't spend a lot of time working with WinUI so I really appreciate input from developers like you who are much more familiar with the platform. I'm going to merge this now and I intend to publish a new set of NuGet packages within the next few weeks.

Thanks again! 🚀
Scott

@swharden swharden enabled auto-merge (squash) July 29, 2025 20:06
@swharden swharden merged commit cfdfb8a into ScottPlot:main Jul 29, 2025
3 checks passed
@diluculo diluculo deleted the add-keymodifier-support branch July 30, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WinUI ScottPlot: How to properly detect keyboard modifiers in custom UserActionResponse (Ctrl+MouseWheel zoom)

2 participants