-
Notifications
You must be signed in to change notification settings - Fork 711
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
WinUI crashes when attempting to use Oemcomma as Key in accelerator #708
Comments
Thanks for reporting this - we have a bug in how we look up the localized string for the VK_OEM_COMMA accelerator. To workaround this for now, you can provide your own string in MenuFlyoutItem.KeyboardAcceleratorTextOverride property, which prevents us from trying to create our string. This bug is in the framework rather than the controls, so we can't fix this directly in WinUI yet - but will try to look into it for WinUI 3. |
This commit introduces support for key bindings containing keys traditionally classified as "OEM" keys. It uses VkKeyScanW and MapVirtualKeyW, and translates the modifiers that come out of VkKeyScanW to key chord modifiers. The net result of this is that you can use bindings like "ctrl+|" in your settings. That one in particular will be reserialized (and displayed in any menus) as "ctrl+shift+\". Admittedly, this is not clear, but it _is_ the truest representation of the key. This commit also moves the Xaml key chord name override generator into App as a static function, *AND* it forces its use for all modifier names. This will present a localization issue, which will be helped in part by #1972. This is required to work around microsoft/microsoft-ui-xaml#708. I've kept the original code around guarded by a puzzling ifdef, because it absolutely has value. Fixes #1212.
This commit introduces support for key bindings containing keys traditionally classified as "OEM" keys. It uses VkKeyScanW and MapVirtualKeyW, and translates the modifiers that come out of VkKeyScanW to key chord modifiers. The net result of this is that you can use bindings like "ctrl+|" in your settings. That one in particular will be reserialized (and displayed in any menus) as "ctrl+shift+\". Admittedly, this is not clear, but it _is_ the truest representation of the key. This commit also moves the Xaml key chord name override generator into App as a static function, *AND* it forces its use for all modifier names. This will present a localization issue, which will be helped in part by #1972. This is required to work around microsoft/microsoft-ui-xaml#708. I've kept the original code around guarded by a puzzling ifdef, because it absolutely has value. Fixes #1212.
FWIW, this happens for almost all |
This commit introduces support for key bindings containing keys traditionally classified as "OEM" keys. It uses VkKeyScanW and MapVirtualKeyW, and translates the modifiers that come out of VkKeyScanW to key chord modifiers. The net result of this is that you can use bindings like "ctrl+|" in your settings. That one in particular will be reserialized (and displayed in any menus) as "ctrl+shift+\". Admittedly, this is not clear, but it _is_ the truest representation of the key. This commit also moves the Xaml key chord name override generator into App as a static function, *AND* it forces its use for all modifier names. This will present a localization issue, which will be helped in part by #1972. This is required to work around microsoft/microsoft-ui-xaml#708. I've kept the original code around guarded by a puzzling ifdef, because it absolutely has value. Fixes #1212.
@DHowett-MSFT - yeah, the bug is about a range check we do. Can you please add to this issue the list of all the VK_* entries that you'd want supported so we're sure to get them all when we address this? |
This issue means that you can't use the common key shortcuts ctrl+= (VK_OEM_PLUS) and ctrl+- (VK_OEM_MINUS) to zoom in and out, would be great if it was fixed in WinUI 3. |
This commit introduces support for key bindings containing keys traditionally classified as "OEM" keys. It uses VkKeyScanW and MapVirtualKeyW, and translates the modifiers that come out of VkKeyScanW to key chord modifiers. The net result of this is that you can use bindings like "ctrl+|" in your settings. That one in particular will be reserialized (and displayed in any menus) as "ctrl+shift+\". Admittedly, this is not clear, but it _is_ the truest representation of the key. This commit also moves the Xaml key chord name override generator into App as a static function, *AND* it forces its use for all modifier names. This will present a localization issue, which will be helped in part by #1972. This is required to work around microsoft/microsoft-ui-xaml#708. I've kept the original code around guarded by a puzzling ifdef, because it absolutely has value. Fixes #1212.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Confirmed bug with product team.
Description
When creating a KeyboardAccelerator with a Modifier and Key, the runtime will crash when attempting to use a comma as the key.
Repro Steps
Create a UWP blank app
XAML:
C#:
Expected
Button launches a flyout with a menu item showing "Control + ," as the label
Actual
Crashes at:
Windows.UI.Xaml.dll!GetResourceStringIdFromVirtualKey(Windows::System::VirtualKey key) Line 330 C++
Windows.UI.Xaml.dll!DirectUI::KeyboardAccelerator::ConcatVirtualKey(Windows::System::VirtualKey key, Windows::Internal::String & keyboardAcceleratorString) Line 126 C++
Windows.UI.Xaml.dll!DirectUI::KeyboardAccelerator::GetStringRepresentation(HSTRING__ * * stringRepresentation) Line 116 C++
Windows.UI.Xaml.dll!DirectUI::KeyboardAccelerator::GetStringRepresentationForUIElement(DirectUI::UIElement * uiElement, HSTRING__ * * stringRepresentation) Line 78 C++
Windows.UI.Xaml.dll!DirectUI::MenuFlyoutItem::get_KeyboardAcceleratorTextOverrideImpl(HSTRING__ * * pValue) Line 851 C++
when trying to lookup the resource for the comma character.
The text was updated successfully, but these errors were encountered: