Permalink
Browse files

Merge pull request #26 from bjhomer/pull-requests/behavior-fixes

Bug fixes.
  • Loading branch information...
2 parents 5feb558 + 25f437c commit 560d3d68868e12bc7e1e7c0082a27c770e09f4b8 @jasarien committed Mar 21, 2013
Showing with 6 additions and 2 deletions.
  1. +4 −1 JSTokenField/JSBackspaceReportingTextField.m
  2. +2 −1 JSTokenField/JSTokenField.m
@@ -11,8 +11,11 @@
@implementation JSBackspaceReportingTextField
- (void)deleteBackward {
+ BOOL shouldDismiss = (self.text.length == 0);
+
[super deleteBackward];
- if (self.text.length == 0) {
+
+ if (shouldDismiss) {
if ([self.delegate respondsToSelector:@selector(textField:shouldChangeCharactersInRange:replacementString:)]) {
[self.delegate textField:self shouldChangeCharactersInRange:NSMakeRange(0, 0) replacementString:@""];
}
@@ -374,7 +374,8 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang
NSString *name = [token titleForState:UIControlStateNormal];
// If we don't allow deleting the token, don't even bother letting it highlight
- if ([self.delegate tokenField:self shouldRemoveToken:name representedObject:token.representedObject]) {
+ BOOL responds = [self.delegate respondsToSelector:@selector(tokenField:shouldRemoveToken:representedObject:)];
+ if (responds == NO || [self.delegate tokenField:self shouldRemoveToken:name representedObject:token.representedObject]) {
[token becomeFirstResponder];
}
return NO;

0 comments on commit 560d3d6

Please sign in to comment.