-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update RadialGauge to use KeyboardAccelerators #4456
Conversation
Replace KeyDown event handling by KeyboardAccelerators. This does not change the behavior. It improves performance by not reacting to just any key stroke. I also removes the call to CoreWindow.GetKeyState - an API that doesn't exist in WinUI 3.
Thanks XamlBrewer for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
Microsoft.Toolkit.Uwp.UI.Controls.Input/RadialGauge/RadialGauge.cs
Outdated
Show resolved
Hide resolved
Fixed StyleCop issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After testing RadialGauge on both main
and then this branch, this PR has caused a regression.
- Open the RadialGauge sample
Tab
until the selection rectangle is around the radial gauge- Press the arrow keys on the keyboard. Nothing happens, when it should change the value
I guess it makes sense to create a Toolkit Labs Experiment for this control, so we can easily debug on all platforms (UWP, WinUI 3, UNO). |
The plan after the upcoming hotfix is to bring the labs infrastructure to the main repo so we can merge all our branches together. If you do want to test in the interim across both though, copying over to a Labs environment does work. We've done it for a few things we've been working on like the new GridSplitter. |
The migration to Labs will take place as 8.0. We'd like to include this as a hotfix in 7.1.3/7.2, so we'll need to fix the regression before moving forward @XamlBrewer |
To me, the most probable reason for this is that you forgot to set 'IsInteractive' to True. The control only listens to keystrokes and touch gestures when it is in interactive mode. I'm pretty confident about the source code - I can share a simple UWP host app running this exact version if you want. Other possibility: mismatch between 'Maximum' (default 1, from RangeBase) and 'SmallChange'/'LargeChange' (set to 1 and 10 in the constructor - maybe not the best idea). In that case you might not see changes when using arrow keys. |
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 30 days of this comment. |
@XamlBrewer Looks like the arrow keys only work when the Ctrl key is pressed, and only after reducing the StepSize |
The default values for Minimum, Maximum, StepSize, SmallChange, and LargeChange are not ideal, but they did not change since 2018 (unless there was a change in RangeBase). So I do not understand how this PR can create a regression in this domain. |
@Arlodotexe When you configure SmallChange and/or LargeChange to be smaller than the StepSize, then you can't change the Value using the arrow keys - since the result is rounded back to the original Value. To me, this is expected behavior. As a workaround we could use Max(*Change, StepSize) as increment or decrement in the keyboard accelerators. But then we're basically ignoring the property values set by the developer. How do other controls (like the Slider) deal with this? |
This line wasn't carried over during the refactor. I've pushed a commit that fixes the regression while using the new code. |
Microsoft.Toolkit.Uwp.UI.Controls.Input/RadialGauge/RadialGauge.cs
Outdated
Show resolved
Hide resolved
Microsoft.Toolkit.Uwp.UI.Controls.Input/RadialGauge/RadialGauge.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behavior works the same as before, seems great! Thanks @XamlBrewer and @Arlodotexe for looking at this.
Just a quick thing I noticed around the event lifetime though. @Arlodotexe since it effects things outside this PR as well, let me know your thoughts on if we just want to snap this and then open another PR to fix the event registration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with team, opened #4784 to follow up this PR. But we're good to merge this one. Thanks!
Replace KeyDown event handling by KeyboardAccelerators. This does not change the behavior. It improves performance by not reacting to just any key stroke. I also removes the call to CoreWindow.GetKeyState - an API that doesn't exist in WinUI 3.
Fixes
Replace KeyDown event handling by KeyboardAccelerators.
PR Type
What kind of change does this PR introduce?
Refactoring (no functional changes, no api changes)
What is the current behavior?
The value can be manipulated via keyboard input: arrows, with our without CTRL.
What is the new behavior?
The same.
It improves performance by not reacting to just any key stroke. I also removes the call to CoreWindow.GetKeyState - an API that doesn't exist in WinUI 3. It is possible to create a RadialGauge control for WinUI 2 (UWP) as well as WinUI3 (Win32) from the same source code, and this modification brings this situation closer.
PR Checklist
Please check if your PR fulfills the following requirements:
Other information