Mercurial > hg > tweakathon2ios
view UsernameAlertViewController.mm @ 2:851833072cf1
panel has 8 sliders if needed.
sliders should get set by midi input.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 10 Oct 2014 18:13:24 +0100 |
parents | a223551fdc1f |
children | d5e928887f51 |
line wrap: on
line source
// // iViewController.m // oscSenderExample // // Created by Robert Tubb on 07/01/2013. // // #include "testApp.h" #include "eventLogger.h" #import "usernameAlertViewController.h" extern EventLogger eventLogger; @implementation UsernameAlertViewController -(void)showUserNamePrompt{ self.alert = [[UIAlertView alloc] initWithTitle:@"Hello!" message:@"Please enter your name:" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil]; self.alert.alertViewStyle = UIAlertViewStylePlainTextInput; UITextField * alertTextField = [self.alert textFieldAtIndex:0]; [alertTextField setDelegate:self]; alertTextField.keyboardType = UIKeyboardTypeDefault; alertTextField.placeholder = @"Username"; [self.alert show]; //[self.alert release]; } -(void)setAppRef:(id)theAppRef{ self.theOFAppRef = theAppRef; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"Entered: %@",[[alertView textFieldAtIndex:0] text]); NSString *userName = [[alertView textFieldAtIndex:0] text]; if ([userName isEqualToString:@""]){ [self showUserNamePrompt]; return; } eventLogger.setUsername([userName cStringUsingEncoding:NSASCIIStringEncoding]); // call some start func ((testApp *)self.theOFAppRef)->usernameEntered(); // rememebr to change return func too! } -(BOOL)textFieldShouldReturn:(UITextField *)textField{ NSLog(@"Entered: %@",[[self.alert textFieldAtIndex:0] text]); NSString *userName = [[self.alert textFieldAtIndex:0] text]; if ([userName isEqualToString:@""]){ [self showUserNamePrompt]; }else{ eventLogger.setUsername([userName cStringUsingEncoding:NSASCIIStringEncoding]); ((testApp *)self.theOFAppRef)->startTheTests(); } [self.alert dismissWithClickedButtonIndex:self.alert.firstOtherButtonIndex animated:YES]; return YES; } - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView { UITextField *textField = [alertView textFieldAtIndex:0]; if ([textField.text length] == 0) { return NO; } return YES; } @end // global. again.