From 48a1337c041aa9eaa1f11b50e3cd1cde0ca386ec Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Wed, 21 Aug 2024 11:31:31 +0200 Subject: [PATCH] chore: Adjustments to key handling --- .../UI/Xaml/Controls/ComboBox/ComboBox.custom.cs | 10 +++++++++- .../UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.custom.cs b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.custom.cs index 0fbd3012b93f..6c241e7bfee3 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.custom.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.custom.cs @@ -1,7 +1,7 @@ #nullable enable using System; -using Microsoft.UI.Xaml.Automation.Peers; +using DirectUI; using Microsoft.UI.Xaml.Controls.Primitives; using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Input; @@ -369,6 +369,14 @@ internal bool TryHandleKeyDown(KeyRoutedEventArgs args, ComboBoxItem? focusedCon return false; } + var nModifierKeys = CoreImports.Input_GetKeyboardModifiers(); + + // Editable and Alt key are handled in ported code. + if (IsEditable || 0 != (nModifierKeys & VirtualKeyModifiers.Menu)) + { + return false; + } + if (args.Key == VirtualKey.Down) { if (IsDropDownOpen) diff --git a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs index a703240587f5..fe23a98006e3 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs @@ -1692,13 +1692,15 @@ private void PopupKeyDown(KeyRoutedEventArgs args) { newFocusedIndex = newFocusedIndex < 0 ? 0 : newFocusedIndex; } + break; } else if (0 != (nModifierKeys & VirtualKeyModifiers.Menu)) { IsDropDownOpen = false; handled = true; + break; } - break; + goto case VirtualKey.Home; case VirtualKey.Home: case VirtualKey.End: case VirtualKey.PageUp: