@@ -385,48 +385,14 @@ void RefreshRecentProjects()
385385 //
386386 //
387387
388-
389- //private void OnSearchPreviewKeyDown(object sender, KeyEventArgs e)
390- //{
391- // switch (e.Key)
392- // {
393- // case Key.Escape:
394- // if (((TextBox)sender).Text == "")
395- // {
396- // Console.WriteLine(1);
397- // Keyboard.Focus(gridRecent);
398- // e.Handled = true;
399- // }
400- // ((TextBox)sender).Text = "";
401- // break;
402- // default:
403- // break;
404- // }
405- //}
406-
388+ // maximize window
407389 void NotifyIcon_MouseClick ( object sender , System . Windows . Forms . MouseEventArgs e )
408390 {
409391 this . Show ( ) ;
410392 this . WindowState = WindowState . Normal ;
411393 notifyIcon . Visible = false ;
412- }
413-
414- // hide/show notifyicon based on window state
415- private void Window_StateChanged ( object sender , EventArgs e )
416- {
417- if ( this . WindowState == WindowState . Minimized )
418- {
419- this . ShowInTaskbar = false ;
420- notifyIcon . BalloonTipTitle = "Minimize Sucessful" ;
421- notifyIcon . BalloonTipText = "Minimized the app " ;
422- notifyIcon . ShowBalloonTip ( 400 ) ;
423- notifyIcon . Visible = true ;
424- }
425- else if ( this . WindowState == WindowState . Normal )
426- {
427- notifyIcon . Visible = false ;
428- this . ShowInTaskbar = true ;
429- }
394+ // NOTE workaround for grid not focused when coming back from minimized window
395+ Tools . SetFocusToGrid ( gridRecent , GetSelectedProjectIndex ( ) ) ;
430396 }
431397
432398 private void OnRectangleMouseDown ( object sender , MouseButtonEventArgs e )
@@ -512,9 +478,14 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
512478 case Key . Escape : // clear project search
513479 if ( txtSearchBox . Text == "" )
514480 {
515- if ( txtSearchBox . IsFocused ) Tools . SetFocusToGrid ( gridRecent ) ;
481+ // its already clear
516482 }
517- txtSearchBox . Text = "" ;
483+ else // we have text in searchbox
484+ {
485+ txtSearchBox . Text = "" ;
486+ }
487+ // try to keep selected row selected and in view
488+ Tools . SetFocusToGrid ( gridRecent ) ;
518489 break ;
519490 case Key . F5 :
520491 txtSearchBox . Text = "" ;
@@ -523,6 +494,7 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
523494 case Key . Left :
524495 case Key . Right :
525496 case Key . Down :
497+ break ;
526498 case Key . F2 : // edit arguments
527499 break ;
528500 default : // any key
@@ -757,8 +729,8 @@ private void TxtSearchBox_PreviewKeyDown(object sender, KeyEventArgs e)
757729 //}
758730 //else
759731 //{
760- Tools . SetFocusToGrid ( gridRecent ) ;
761- // }
732+ Tools . SetFocusToGrid ( gridRecent ) ;
733+ // }
762734 e . Handled = true ; // to stay in first row
763735 break ;
764736 default :
@@ -795,15 +767,11 @@ private void BtnRemoveInstallationFolder_Click(object sender, RoutedEventArgs e)
795767 }
796768 }
797769
798- // need to manually move into next/prev rows? https://stackoverflow.com/a/11652175/5452781
770+ // need to manually move into next/prev rows? Not using https://stackoverflow.com/a/11652175/5452781
799771 private void GridRecent_PreviewKeyDown ( object sender , KeyEventArgs e )
800772 {
801773 switch ( e . Key )
802774 {
803- case Key . Up :
804- case Key . Down :
805- break ;
806-
807775 case Key . F5 : // refresh projects
808776 RefreshRecentProjects ( ) ;
809777 break ;
@@ -1153,5 +1121,11 @@ private void MenuItemSetPreferredUnityVersion_Click(object sender, RoutedEventAr
11531121 UpdateUnityInstallationsList ( ) ;
11541122
11551123 }
1124+
1125+ private void Window_Activated ( object sender , EventArgs e )
1126+ {
1127+ //Console.WriteLine("gridRecent.IsFocused=" + gridRecent.IsFocused);
1128+ //Console.WriteLine("gridRecent.IsFocused=" + gridRecent.IsKeyboardFocused);
1129+ }
11561130 } // class
11571131} //namespace
0 commit comments