From 2725e167b47d45b7d6aebf84426090d60b7c30c5 Mon Sep 17 00:00:00 2001 From: floele Date: Sat, 30 Jan 2016 18:20:02 +0100 Subject: [PATCH 1/3] Menu navigation working for the post part Still not working: Focus WinForms Textbox, navigate into submenu and use "Left" key to go back to the previous menu. --- Fluent.Ribbon/Controls/MenuItem.cs | 9 ++++++++ Fluent.Ribbon/Services/KeyTipService.cs | 30 +++++++++++++++++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/Fluent.Ribbon/Controls/MenuItem.cs b/Fluent.Ribbon/Controls/MenuItem.cs index 13a791150..70f73159e 100644 --- a/Fluent.Ribbon/Controls/MenuItem.cs +++ b/Fluent.Ribbon/Controls/MenuItem.cs @@ -652,6 +652,15 @@ protected override void OnPreviewLostKeyboardFocus(KeyboardFocusChangedEventArgs //e.Handled = true; } + /// + /// Allows KeyTipService to control menu items. + /// + /// + internal void HandleKeyDown(KeyEventArgs e) + { + this.OnKeyDown(e); + } + /// /// Responds to the event. /// diff --git a/Fluent.Ribbon/Services/KeyTipService.cs b/Fluent.Ribbon/Services/KeyTipService.cs index 0eaf26638..e1f7b428b 100644 --- a/Fluent.Ribbon/Services/KeyTipService.cs +++ b/Fluent.Ribbon/Services/KeyTipService.cs @@ -238,12 +238,18 @@ private void OnWindowPreviewKeyDown(object sender, KeyEventArgs e) return; } - // Should we show the keytips and immediately react to key? - if (this.activeAdornerChain == null - || this.activeAdornerChain.IsAdornerChainAlive == false - || this.activeAdornerChain.AreAnyKeyTipsVisible == false) + Key actualKey = e.Key == Key.System ? e.SystemKey : e.Key; + bool isLetterKey = ((actualKey >= Key.A && actualKey <= Key.Z) || (actualKey >= Key.D0 && actualKey <= Key.D9) || (actualKey >= Key.NumPad0 && actualKey <= Key.NumPad9)); + + if (isLetterKey) { - this.ShowImmediatly(); + // Should we show the keytips and immediately react to key? + if (this.activeAdornerChain == null + || this.activeAdornerChain.IsAdornerChainAlive == false + || this.activeAdornerChain.AreAnyKeyTipsVisible == false) + { + this.ShowImmediatly(); + } } if (this.activeAdornerChain == null) @@ -253,11 +259,21 @@ private void OnWindowPreviewKeyDown(object sender, KeyEventArgs e) string previousInput = this.currentUserInput; - this.currentUserInput += keyConverter.ConvertToString(e.Key == Key.System ? e.SystemKey : e.Key); + if (isLetterKey) + { + this.currentUserInput += keyConverter.ConvertToString(actualKey); + } // If no key tips match the current input, continue with the previously entered and still correct keys. - if (this.activeAdornerChain.ActiveKeyTipAdorner.ContainsKeyTipStartingWith(this.currentUserInput) == false) + if (!isLetterKey || this.activeAdornerChain.ActiveKeyTipAdorner.ContainsKeyTipStartingWith(this.currentUserInput) == false) { + MenuItem item = Keyboard.FocusedElement as MenuItem; + if (item != null && !isLetterKey) + { + item.HandleKeyDown(e); + return; + } + this.currentUserInput = previousInput; System.Media.SystemSounds.Beep.Play(); } From 2c539f1296ccdf3debcd1d51f1c2606a9541328b Mon Sep 17 00:00:00 2001 From: floele-sp Date: Tue, 29 Mar 2016 14:34:22 +0200 Subject: [PATCH 2/3] Fixed icon alignment in DropDownButton, ToggleButton, Button (compared to SplitButton) --- Fluent.Ribbon/Themes/Office2013/Controls/Button.xaml | 4 ++-- Fluent.Ribbon/Themes/Office2013/Controls/DropDownButton.xaml | 4 ++-- Fluent.Ribbon/Themes/Office2013/Controls/ToggleButton.xaml | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Fluent.Ribbon/Themes/Office2013/Controls/Button.xaml b/Fluent.Ribbon/Themes/Office2013/Controls/Button.xaml index d3d88f03d..767138c14 100644 --- a/Fluent.Ribbon/Themes/Office2013/Controls/Button.xaml +++ b/Fluent.Ribbon/Themes/Office2013/Controls/Button.xaml @@ -56,7 +56,7 @@ Value="16" /> + Value="2,0,2,0" /> @@ -92,7 +92,7 @@ Value="16" /> + Value="2,0,2,0" /> diff --git a/Fluent.Ribbon/Themes/Office2013/Controls/DropDownButton.xaml b/Fluent.Ribbon/Themes/Office2013/Controls/DropDownButton.xaml index 13da567e4..b98027e03 100644 --- a/Fluent.Ribbon/Themes/Office2013/Controls/DropDownButton.xaml +++ b/Fluent.Ribbon/Themes/Office2013/Controls/DropDownButton.xaml @@ -214,7 +214,7 @@ Value="16" /> + Value="2,0,0,0" /> @@ -256,7 +256,7 @@ Value="16" /> + Value="2,0,2,0" /> diff --git a/Fluent.Ribbon/Themes/Office2013/Controls/ToggleButton.xaml b/Fluent.Ribbon/Themes/Office2013/Controls/ToggleButton.xaml index fa8baf085..ec4f613eb 100644 --- a/Fluent.Ribbon/Themes/Office2013/Controls/ToggleButton.xaml +++ b/Fluent.Ribbon/Themes/Office2013/Controls/ToggleButton.xaml @@ -28,6 +28,8 @@ Value="Middle"> + @@ -35,6 +37,8 @@ Value="22" /> + From e4a31acc1a39cd36415b7fc5facfffbd07210d08 Mon Sep 17 00:00:00 2001 From: floele-sp Date: Tue, 29 Mar 2016 14:37:59 +0200 Subject: [PATCH 3/3] Reverted to upstream version --- Fluent.Ribbon/Controls/MenuItem.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Fluent.Ribbon/Controls/MenuItem.cs b/Fluent.Ribbon/Controls/MenuItem.cs index 70f73159e..13a791150 100644 --- a/Fluent.Ribbon/Controls/MenuItem.cs +++ b/Fluent.Ribbon/Controls/MenuItem.cs @@ -652,15 +652,6 @@ protected override void OnPreviewLostKeyboardFocus(KeyboardFocusChangedEventArgs //e.Handled = true; } - /// - /// Allows KeyTipService to control menu items. - /// - /// - internal void HandleKeyDown(KeyEventArgs e) - { - this.OnKeyDown(e); - } - /// /// Responds to the event. ///