Browse files

Merge pull request #12 from eldenchen/master

The 'initialKeyView' method did not work correctly.
  • Loading branch information...
2 parents b78381e + ca4a98d commit 8f3de32e412026989f66234b46a2be2aedb724a7 @shpakovski committed Oct 4, 2012
Showing with 1 addition and 2 deletions.
  1. +1 −2 MASPreferencesWindowController.m
@@ -1,4 +1,3 @@
#import "MASPreferencesWindowController.h"
NSString *const kMASPreferencesWindowControllerDidChangeViewNotification = @"MASPreferencesWindowControllerDidChangeViewNotification";
@@ -268,7 +267,7 @@ - (void)setSelectedViewController:(NSViewController <MASPreferencesViewControlle
[self.window recalculateKeyViewLoop];
if ([self.window firstResponder] == self.window) {
if ([controller respondsToSelector:@selector(initialKeyView)])
- [self.window makeFirstResponder:[controller initialKeyView]];
+ [self.window performSelector:@selector(makeFirstResponder:) withObject:[controller initialKeyView] afterDelay:0];
[self.window selectKeyViewFollowingView:controllerView];

3 comments on commit 8f3de32


Why did it not work? I think the commit message should state that.

Ideally a solution not involving performSelector:withObject:afterDelay: would be devised. I.e. I think this is an issue of the user not having the stuff fully setup when the initial first responder is set, so perhaps it should be moved to the proper callback, rather than do it after the current event loop iteration and hope things are properly setup at that time.

P.S. Quite sure my use of MASPreferences does not reveal any problem setting custom first responders.


I have just re-checked the initial solution and it seems to be working too. Sorry for confusion, I rolled it back.


It's all my fault, I attempted to set NSButton(checkbox) as initial first responder when system wide "All Controls" focus setting is not checked.

Now, the issue is that NSButton can't be initial first responder when the window appears for the first time, but it works after switching views.

Please sign in to comment.