Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug fixes. #26

Merged
merged 2 commits into from

3 participants

@bjhomer

This includes a couple bug fixes.

  1. I was calling an @optional delegate method without checking if the delegate implements it. This was added in one of my previous pull requests. Sorry!

  2. A bug in the delete-backward detection made it select the previous JSTokenButton when you deleted the last character, rather than when you hit delete and there were already no characters. Also my fault.

siuying and others added some commits
@siuying siuying Improve how token field handle Backspace and highligh token
Highlight token only when text field has NO text and user press backward (rather than the text field have ONE character and user press backward)
aba5c4c
@bjhomer bjhomer Check respondsToSelector before calling an @optional delegate method.
Oops.
25f437c
@jasarien jasarien merged commit 560d3d6 into from
@bjhomer bjhomer deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 21, 2013
  1. @siuying @bjhomer

    Improve how token field handle Backspace and highligh token

    siuying authored bjhomer committed
    Highlight token only when text field has NO text and user press backward (rather than the text field have ONE character and user press backward)
  2. @bjhomer
This page is out of date. Refresh to see the latest.
View
5 JSTokenField/JSBackspaceReportingTextField.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:@""];
}
View
3  JSTokenField/JSTokenField.m
@@ -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;
Something went wrong with that request. Please try again.