-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add a new TypeConverter for ToolStripMenuItem.ShortcutKeys
that does not provide standard items
#13039
Conversation
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.
PR Overview
This PR introduces a new ShortcutKeysConverter that disables the provision of standard shortcut key values for ToolStripMenuItem.ShortcutKeys, addressing an issue where standard values were erroneously reported. The changes include:
- Adding a new ShortcutKeysConverter class and corresponding tests.
- Updating ToolStripMenuItem to use the new converter and improving layout transaction calls.
- Adjusting test naming and minor cleanups in supporting files.
Reviewed Changes
File | Description |
---|---|
tests/UnitTests/System/Windows/Forms/ShortcutKeysConverterTests.cs | Adds tests for the new converter ensuring no standard values are provided. |
src/System/Windows/Forms/Controls/ToolStrips/ShortcutKeysConverter.cs | Introduces the new converter with empty standard values and GetStandardValuesSupported returning false. |
tests/UnitTests/System/Windows/Forms/PropertyGridTests.cs | Adds a regression test to validate mouse wheel behavior on shortcut keys in the PropertyGrid. |
src/System/Windows/Forms/Controls/ToolStrips/ToolStripMenuItem.cs | Applies the new converter attribute and improves tooltip layout calls using nameof(). |
src/System.Private.Windows.Core/src/System/SpanHelpers.cs | Removes obsolete pragma warning directives around string termination. |
tests/UnitTests/System/Windows/Forms/PropertyGridInternal/PropertyGridView.DropDownHolderTests.cs | Renames a test method for clarity. |
src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs | Reformats a conditional check for improved readability. |
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/System.Private.Windows.Core/src/System/SpanHelpers.cs:24
- [nitpick] The removal of #pragma warning disable/restore suggests that the assignment's potential warning is now expected; please add a comment clarifying that this assignment is intentional to prevent new IDE warnings.
destination[source.Length] = '\0';
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridTests.cs
Outdated
Show resolved
Hide resolved
662175b
to
efa2102
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13039 +/- ##
===================================================
- Coverage 76.14135% 76.11217% -0.02918%
===================================================
Files 3275 3277 +2
Lines 643775 643809 +34
Branches 47441 47443 +2
===================================================
- Hits 490179 490017 -162
- Misses 150036 150237 +201
+ Partials 3560 3555 -5
Flags with carried forward coverage won't be shown. Click here to find out more. |
efa2102
to
6d6eba1
Compare
src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ShortcutKeysConverter.cs
Outdated
Show resolved
Hide resolved
…er does not provide standard items
6d6eba1
to
599e6d7
Compare
Fixes #12982
Proposed changes
ToolStripMenuItem.ShortcutKeys
property type (Keys enum) has a TypeConverter that reports that it has a set of standard values. This is not entirely accurate.Keys
type has a set of standard values, but theShortcutKeys
property does not, even the ShortcutKeys type contains different key combinations from what can be generated by the shortcut key editor. Shortcuts are combinations of keys and modifiers, it's not practical to present all combinations for user to step through with up/down keys or with mouse wheel. To disable this behavior, we need to add a new TypeConverter that does not provide standard values.I would like to add a new TypeConverter to this property.
KeysConverter
is defined on the Keys enum, the property does not have one right now. TypeDescriptor prioretizes attributese defined on properties over those defined on property types. This change is "borderline" allowed depending on whether this is considered a changed attribute or a new one https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/breaking-change-rules.md#attributes.We don't have any other public instance properties of type Keys.
This behavior regressed when we added Keys.None value to the list of standard values - #8401. This was done to localize "None" (as "(none)") in the property grid. When the current value of the shortcut is not one of the standard values, property grid entry does not enter the "scroll through the standard items" functionality. This is a beneficial change, I'd prefer to keep it.
Video.Project.3.mp4
Microsoft Reviewers: Open in CodeFlow