Mercurial > hg > soniczoomios
diff PresetAlertViewController.mm @ 31:23ef179c3748
Ben / Christian 0.2
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 01 Mar 2013 13:28:45 +0000 |
parents | c0a6f7c66719 |
children | ab7c86d0f3d8 |
line wrap: on
line diff
--- a/PresetAlertViewController.mm Wed Feb 27 11:39:07 2013 +0000 +++ b/PresetAlertViewController.mm Fri Mar 01 13:28:45 2013 +0000 @@ -6,6 +6,7 @@ // // #include "presetManager.h" +#include "testApp.h" #import "PresetAlertViewController.h" @@ -26,18 +27,19 @@ } - (void)showPresetNamePrompt{ - UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Save" + self.alert = [[UIAlertView alloc] initWithTitle:@"Save" message:@"Enter preset name:" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Enter",nil]; - alert.alertViewStyle = UIAlertViewStylePlainTextInput; - UITextField * alertTextField = [alert textFieldAtIndex:0]; + self.alert.alertViewStyle = UIAlertViewStylePlainTextInput; + UITextField * alertTextField = [self.alert textFieldAtIndex:0]; + [alertTextField setDelegate:self]; alertTextField.keyboardType = UIKeyboardTypeDefault; alertTextField.placeholder = @"Preset Name"; - [alert show]; + [self.alert show]; self.alertShowing = YES; - [alert release]; + [self.alert release]; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ @@ -56,12 +58,33 @@ }else if([[[alertView textFieldAtIndex:0] text] isEqualToString:@"printall"]){ presetManager.printAll(); eventLogger.printAll(); + }else if([[[alertView textFieldAtIndex:0] text] isEqualToString:@"questionnaire"]){ + ((testApp *)ofGetAppPtr())->interfaceSelected(3); + }else{ presetManager.addPreset([[[alertView textFieldAtIndex:0] text] cStringUsingEncoding:NSASCIIStringEncoding]); } } } +-(BOOL)textFieldShouldReturn:(UITextField *)textField{ + // save it + self.alertShowing = NO; + if([[[self.alert textFieldAtIndex:0] text] isEqualToString:@"newuser"]){ + // call new user stufff + eventLogger.newUser(); + }else if([[[self.alert textFieldAtIndex:0] text] isEqualToString:@"printall"]){ + presetManager.printAll(); + eventLogger.printAll(); + }else if([[[self.alert textFieldAtIndex:0] text] isEqualToString:@"questionnaire"]){ + ((testApp *)ofGetAppPtr())->interfaceSelected(3); + + }else{ + presetManager.addPreset([[[self.alert textFieldAtIndex:0] text] cStringUsingEncoding:NSASCIIStringEncoding]); + } + [self.alert dismissWithClickedButtonIndex:self.alert.firstOtherButtonIndex animated:YES]; + return YES; +} - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView {