Skip to content

Commit

Permalink
Merge pull request #2577 from vishalduggal/timob-9848
Browse files Browse the repository at this point in the history
[TIMOB-9848]iOS: Ti.UI.TextField change event with wrong value
  • Loading branch information
Max Stepanov committed Jul 18, 2012
2 parents cb66b60 + d0065cd commit 7ad260f
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions iphone/Classes/TiUITextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -469,25 +469,12 @@ - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField; // return N

- (BOOL)textField:(UITextField *)tf shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSString *curText = [tf text];
NSString *curText = [[tf text] stringByReplacingCharactersInRange:range withString:string];

NSInteger maxLength = [[self textWidgetView] maxLength];
if (maxLength > -1) {
NSInteger length = [curText length] + [string length] - range.length;

if (length > maxLength) {
return NO;
}
if ( (maxLength > -1) && ([curText length] > maxLength) ) {
return NO;
}

if ([string isEqualToString:@""])
{
curText = [curText substringToIndex:[curText length]-range.length];
}
else
{
curText = [NSString stringWithFormat:@"%@%@",curText,string];
}

[(TiUITextFieldProxy *)self.proxy noteValueChange:curText];
return YES;
Expand Down

0 comments on commit 7ad260f

Please sign in to comment.