Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification for secondary click on selected token #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions JSTokenField/JSTokenField.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 8 additions & 3 deletions JSTokenField/JSTokenField.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#import <QuartzCore/QuartzCore.h>

NSString *const JSTokenFieldFrameDidChangeNotification = @"JSTokenFieldFrameDidChangeNotification";
NSString *const JSTokenFieldTokenSecondTapNotification = @"JSTokenFieldTokenSecondTapNotification";
NSString *const JSTokenFieldNewFrameKey = @"JSTokenFieldNewFrameKey";
NSString *const JSTokenFieldOldFrameKey = @"JSTokenFieldOldFrameKey";
NSString *const JSDeletedTokenKey = @"JSDeletedTokenKey";
Expand Down Expand Up @@ -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];
}
Expand Down