Skip to content

Commit f2a37df

Browse files
nrileypieter
authored andcommitted
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.
1 parent 7baf854 commit f2a37df

5 files changed

+17
-0
lines changed

PBGitCommitController.m

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ - (void) removeView
4747
[webController closeView];
4848
[super finalize];
4949
}
50+
- (NSResponder *)firstResponder;
51+
{
52+
return commitMessageView;
53+
}
5054

5155
- (IBAction)signOff:(id)sender
5256
{

PBGitHistoryController.m

+5
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ - (void) updateView
179179
[self refresh:nil];
180180
}
181181

182+
- (NSResponder *)firstResponder;
183+
{
184+
return commitList;
185+
}
186+
182187
- (void) selectCommit: (NSString*) commit
183188
{
184189
NSPredicate* selection = [NSPredicate predicateWithFormat:@"realSha == %@", commit];

PBGitWindowController.m

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ - (void)changeViewController:(NSInteger)whichViewTag
100100
[self setNextResponder: viewController];
101101
[self didChangeValueForKey:@"viewController"]; // this will trigger the NSTextField's value binding to change
102102

103+
[[self window] makeFirstResponder:[viewController firstResponder]];
103104
}
104105

105106
- (void)awakeFromNib

PBViewController.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller;
2424
- (void) removeView;
2525
- (void) updateView;
26+
- (NSResponder *)firstResponder;
27+
2628
@end

PBViewController.m

+5
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ - (void) awakeFromNib
4040
- (void) updateView
4141
{
4242
}
43+
44+
- (NSResponder *)firstResponder;
45+
{
46+
return nil;
47+
}
4348
@end

0 commit comments

Comments
 (0)