@@ -385,48 +385,14 @@ void RefreshRecentProjects()
385
385
//
386
386
//
387
387
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
407
389
void NotifyIcon_MouseClick ( object sender , System . Windows . Forms . MouseEventArgs e )
408
390
{
409
391
this . Show ( ) ;
410
392
this . WindowState = WindowState . Normal ;
411
393
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 ( ) ) ;
430
396
}
431
397
432
398
private void OnRectangleMouseDown ( object sender , MouseButtonEventArgs e )
@@ -512,9 +478,14 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
512
478
case Key . Escape : // clear project search
513
479
if ( txtSearchBox . Text == "" )
514
480
{
515
- if ( txtSearchBox . IsFocused ) Tools . SetFocusToGrid ( gridRecent ) ;
481
+ // its already clear
516
482
}
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 ) ;
518
489
break ;
519
490
case Key . F5 :
520
491
txtSearchBox . Text = "" ;
@@ -523,6 +494,7 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
523
494
case Key . Left :
524
495
case Key . Right :
525
496
case Key . Down :
497
+ break ;
526
498
case Key . F2 : // edit arguments
527
499
break ;
528
500
default : // any key
@@ -757,8 +729,8 @@ private void TxtSearchBox_PreviewKeyDown(object sender, KeyEventArgs e)
757
729
//}
758
730
//else
759
731
//{
760
- Tools . SetFocusToGrid ( gridRecent ) ;
761
- // }
732
+ Tools . SetFocusToGrid ( gridRecent ) ;
733
+ // }
762
734
e . Handled = true ; // to stay in first row
763
735
break ;
764
736
default :
@@ -795,15 +767,11 @@ private void BtnRemoveInstallationFolder_Click(object sender, RoutedEventArgs e)
795
767
}
796
768
}
797
769
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
799
771
private void GridRecent_PreviewKeyDown ( object sender , KeyEventArgs e )
800
772
{
801
773
switch ( e . Key )
802
774
{
803
- case Key . Up :
804
- case Key . Down :
805
- break ;
806
-
807
775
case Key . F5 : // refresh projects
808
776
RefreshRecentProjects ( ) ;
809
777
break ;
@@ -1153,5 +1121,11 @@ private void MenuItemSetPreferredUnityVersion_Click(object sender, RoutedEventAr
1153
1121
UpdateUnityInstallationsList ( ) ;
1154
1122
1155
1123
}
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
+ }
1156
1130
} // class
1157
1131
} //namespace
0 commit comments