Skip to content

Commit

Permalink
added focus for the buttons via space and enter keys
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhgupta committed Feb 7, 2014
1 parent fe3f5e5 commit a49ba34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Binary file not shown.
7 changes: 7 additions & 0 deletions StopWatch/AppDelegate.m
Expand Up @@ -29,6 +29,9 @@ - (IBAction)start:(id)sender {


// and, make sure that that button says 'Pause' // and, make sure that that button says 'Pause'
[self.stopButton setNextState]; [self.stopButton setNextState];
[self.stopButton setKeyEquivalent:@"\r"];
// space bar should not fire any button
[self.window makeFirstResponder:nil];
} }


- (IBAction)pauseOrResume:(id)sender { - (IBAction)pauseOrResume:(id)sender {
Expand All @@ -38,11 +41,15 @@ - (IBAction)pauseOrResume:(id)sender {
self.timer = nil; self.timer = nil;
// and, enable the start button. // and, enable the start button.
[self.startButton setEnabled:YES]; [self.startButton setEnabled:YES];
// make start button as the first responder
[self.window makeFirstResponder:self.startButton];
} else { } else {
// when the user clicks resume, we resume the watch // when the user clicks resume, we resume the watch
[self startTimer :[self.labelField doubleValue]]; [self startTimer :[self.labelField doubleValue]];
// and, disable the start button. // and, disable the start button.
[self.startButton setEnabled:NO]; [self.startButton setEnabled:NO];
// make start button as the first responder
[self.window makeFirstResponder:nil];
} }
} }


Expand Down

0 comments on commit a49ba34

Please sign in to comment.