diff --git a/JSTokenField/JSTokenField.h b/JSTokenField/JSTokenField.h index 2aa3a83..32e4984 100644 --- a/JSTokenField/JSTokenField.h +++ b/JSTokenField/JSTokenField.h @@ -32,6 +32,8 @@ @protocol JSTokenFieldDelegate; extern NSString *const JSTokenFieldFrameDidChangeNotification; +extern NSString *const JSTokenFieldTokenSecondTapNotification; + extern NSString *const JSTokenFieldNewFrameKey; extern NSString *const JSTokenFieldOldFrameKey; extern NSString *const JSDeletedTokenKey; diff --git a/JSTokenField/JSTokenField.m b/JSTokenField/JSTokenField.m index f607c29..959e2cf 100644 --- a/JSTokenField/JSTokenField.m +++ b/JSTokenField/JSTokenField.m @@ -32,6 +32,7 @@ #import NSString *const JSTokenFieldFrameDidChangeNotification = @"JSTokenFieldFrameDidChangeNotification"; +NSString *const JSTokenFieldTokenSecondTapNotification = @"JSTokenFieldTokenSecondTapNotification"; NSString *const JSTokenFieldNewFrameKey = @"JSTokenFieldNewFrameKey"; NSString *const JSTokenFieldOldFrameKey = @"JSTokenFieldOldFrameKey"; NSString *const JSDeletedTokenKey = @"JSDeletedTokenKey"; @@ -324,12 +325,16 @@ - (void)layoutSubviews - (void)toggle:(id)sender { - for (JSTokenButton *token in _tokens) + JSTokenButton *token = (JSTokenButton *)sender; + if (token.toggled) { + [[NSNotificationCenter defaultCenter] postNotificationName:JSTokenFieldTokenSecondTapNotification object:token]; + } + + for (JSTokenButton *t in _tokens) { - [token setToggled:NO]; + [t setToggled:NO]; } - JSTokenButton *token = (JSTokenButton *)sender; [token setToggled:YES]; [token becomeFirstResponder]; }