@@ -21,6 +21,8 @@ private void AutoSuggestBox_GettingFocus(UIElement sender, GettingFocusEventArgs
2121 if ( args . OldFocusedElement is null )
2222 return ;
2323
24+ GlobalHelper . WriteDebugStringForOmnibar ( "The TextBox is getting the focus." ) ;
25+
2426 _previouslyFocusedElement = new ( args . OldFocusedElement as UIElement ) ;
2527 }
2628
@@ -36,6 +38,8 @@ private void AutoSuggestBox_LosingFocus(UIElement sender, LosingFocusEventArgs a
3638
3739 private void AutoSuggestBox_GotFocus ( object sender , RoutedEventArgs e )
3840 {
41+ GlobalHelper . WriteDebugStringForOmnibar ( "The TextBox got the focus." ) ;
42+
3943 IsFocused = true ;
4044 _textBox . SelectAll ( ) ;
4145 }
@@ -46,6 +50,8 @@ private void AutoSuggestBox_LostFocus(object sender, RoutedEventArgs e)
4650 if ( _textBox . ContextFlyout . IsOpen )
4751 return ;
4852
53+ GlobalHelper . WriteDebugStringForOmnibar ( "The TextBox lost the focus." ) ;
54+
4955 IsFocused = false ;
5056 }
5157
@@ -55,12 +61,16 @@ private async void AutoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)
5561 {
5662 e . Handled = true ;
5763
64+ GlobalHelper . WriteDebugStringForOmnibar ( "The TextBox accepted the Enter key." ) ;
65+
5866 SubmitQuery ( _textBoxSuggestionsPopup . IsOpen && _textBoxSuggestionsListView . SelectedIndex is not - 1 ? _textBoxSuggestionsListView . SelectedItem : null ) ;
5967 }
6068 else if ( ( e . Key == VirtualKey . Up || e . Key == VirtualKey . Down ) && _textBoxSuggestionsPopup . IsOpen )
6169 {
6270 e . Handled = true ;
6371
72+ GlobalHelper . WriteDebugStringForOmnibar ( "The TextBox accepted the Up/Down key while the suggestions pop-up is open." ) ;
73+
6474 var currentIndex = _textBoxSuggestionsListView . SelectedIndex ;
6575 var nextIndex = currentIndex ;
6676 var suggestionsCount = _textBoxSuggestionsListView . Items . Count ;
@@ -89,6 +99,8 @@ private async void AutoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)
8999 {
90100 e . Handled = true ;
91101
102+ GlobalHelper . WriteDebugStringForOmnibar ( "The TextBox accepted the Esc key." ) ;
103+
92104 if ( _textBoxSuggestionsPopup . IsOpen )
93105 {
94106 RevertTextToUserInput ( ) ;
@@ -102,6 +114,8 @@ private async void AutoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)
102114 }
103115 else if ( e . Key == VirtualKey . Tab && ! InputKeyboardSource . GetKeyStateForCurrentThread ( VirtualKey . Shift ) . HasFlag ( CoreVirtualKeyStates . Down ) )
104116 {
117+ GlobalHelper . WriteDebugStringForOmnibar ( "The TextBox accepted the Tab key." ) ;
118+
105119 // Focus on inactive content when pressing Tab instead of moving to the next control in the tab order
106120 e . Handled = true ;
107121 IsFocused = false ;
@@ -136,6 +150,7 @@ private void AutoSuggestBox_TextChanged(object sender, TextChangedEventArgs e)
136150
137151 private void AutoSuggestBoxSuggestionsPopup_GettingFocus ( UIElement sender , GettingFocusEventArgs args )
138152 {
153+ // The suggestions popup is never wanted to be focused when it come to open.
139154 args . TryCancel ( ) ;
140155 }
141156
0 commit comments