Permalink
Browse files

Return focus to window that was previously main window when dismissin…

…g the hud
  • Loading branch information...
calebd committed Feb 1, 2013
1 parent dee4ec0 commit 23872e65f1690173dbad67cb62321c92972ad2b2
Showing with 12 additions and 2 deletions.
  1. +12 −2 SSToolkit/SSHUDView.m
View
@@ -24,6 +24,7 @@ - (void)_removeWindow;
@implementation SSHUDView {
SSHUDWindow *_hudWindow;
+ UIWindow *_keyWindow;
}
@@ -191,6 +192,15 @@ - (void)show {
_hudWindow = [SSHUDWindow defaultWindow];
}
+ id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
+ if ([delegate respondsToSelector:@selector(window)]) {
+ _keyWindow = [delegate performSelector:@selector(window)];
+ }
+ else {
+ // unable to get main window from app delegate
+ _keyWindow = [[UIApplication sharedApplication] keyWindow];
+ }
+
_hudWindow.alpha = 0.0f;
self.alpha = 0.0f;
[_hudWindow addSubview:self];
@@ -350,8 +360,8 @@ - (void)_removeWindow {
[_hudWindow resignKeyWindow];
_hudWindow = nil;
- // Return focus to the first window
- [[[[UIApplication sharedApplication] windows] objectAtIndex:0] makeKeyWindow];
+ // Return focus to the main window
+ [_keyWindow makeKeyWindow];
}
@end

0 comments on commit 23872e6

Please sign in to comment.