From f2a37df9f5cd16057b505e273882e8f836f500d2 Mon Sep 17 00:00:00 2001 From: Nicholas Riley Date: Tue, 16 Jun 2009 23:25:53 -0500 Subject: [PATCH] Set keyboard focus reasonably when switching between views. When you switch to the commit view, the commit message gets focus; when you switch to the history view, the commit list gets focus. --- PBGitCommitController.m | 4 ++++ PBGitHistoryController.m | 5 +++++ PBGitWindowController.m | 1 + PBViewController.h | 2 ++ PBViewController.m | 5 +++++ 5 files changed, 17 insertions(+) diff --git a/PBGitCommitController.m b/PBGitCommitController.m index f3e6664..cec4ffc 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -47,6 +47,10 @@ [webController closeView]; [super finalize]; } +- (NSResponder *)firstResponder; +{ + return commitMessageView; +} - (IBAction)signOff:(id)sender { diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 9c18b72..3b5e9e1 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -179,6 +179,11 @@ [self refresh:nil]; } +- (NSResponder *)firstResponder; +{ + return commitList; +} + - (void) selectCommit: (NSString*) commit { NSPredicate* selection = [NSPredicate predicateWithFormat:@"realSha == %@", commit]; diff --git a/PBGitWindowController.m b/PBGitWindowController.m index b826734..aba1987 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -100,6 +100,7 @@ [self setNextResponder: viewController]; [self didChangeValueForKey:@"viewController"]; // this will trigger the NSTextField's value binding to change + [[self window] makeFirstResponder:[viewController firstResponder]]; } - (void)awakeFromNib diff --git a/PBViewController.h b/PBViewController.h index c3c5901..4715c61 100644 --- a/PBViewController.h +++ b/PBViewController.h @@ -23,4 +23,6 @@ - (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller; - (void) removeView; - (void) updateView; +- (NSResponder *)firstResponder; + @end diff --git a/PBViewController.m b/PBViewController.m index 6cc20a6..510b7a7 100644 --- a/PBViewController.m +++ b/PBViewController.m @@ -40,4 +40,9 @@ - (void) updateView { } + +- (NSResponder *)firstResponder; +{ + return nil; +} @end