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

[TIMOB-15540] Send out row info in tap recognizers #4891

Merged
merged 3 commits into from
Nov 1, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 73 additions & 0 deletions iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,79 @@ -(void)recognizedSwipe:(UISwipeGestureRecognizer *)recognizer
}
}


-(void)recognizedTap:(UITapGestureRecognizer*)recognizer
{
BOOL viaSearch = [searchController isActive];
UITableView* theTableView = viaSearch ? [searchController searchResultsTableView] : [self tableView];
CGPoint point = [recognizer locationInView:theTableView];
CGPoint pointInView = [recognizer locationInView:self];
NSIndexPath* indexPath = nil;

if (viaSearch) {
NSIndexPath* index = [theTableView indexPathForRowAtPoint:point];
if (index != nil) {
indexPath = [self indexPathFromSearchIndex:[index row]];
}
} else {
indexPath = [theTableView indexPathForRowAtPoint:point];
}

NSMutableDictionary *event = [[TiUtils pointToDictionary:pointInView] mutableCopy];
[event setObject:NUMBOOL(NO) forKey:@"detail"];
[event setObject:NUMBOOL(viaSearch) forKey:@"search"];

if (indexPath != nil) {
//We have index path. Let us fill out section and row information. Also since the
int sectionIdx = [indexPath section];
NSArray * sections = [(TiUITableViewProxy *)[self proxy] internalSections];
TiUITableViewSectionProxy *section = [self sectionForIndex:sectionIdx];

int rowIndex = [indexPath row];
int dataIndex = 0;
int c = 0;
TiUITableViewRowProxy *row = [section rowAtIndex:rowIndex];

// unfortunately, we have to scan to determine our row index
for (TiUITableViewSectionProxy *section in sections) {
if (c == sectionIdx) {
dataIndex += rowIndex;
break;
}
dataIndex += [section rowCount];
c++;
}
[event setObject:section forKey:@"section"];
[event setObject:row forKey:@"row"];
[event setObject:row forKey:@"rowData"];
[event setObject:NUMINT(dataIndex) forKey:@"index"];
}


if ([recognizer numberOfTouchesRequired] == 2) {
if ([[self proxy] _hasListeners:@"touchstart"]) {
[[self proxy] fireEvent:@"twofingertap" withObject:event];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Event names don't match

}
}
else if ([recognizer numberOfTapsRequired] == 2) {
//Because double-tap suppresses touchStart and double-click, we must do this:
if ([[self proxy] _hasListeners:@"touchstart"]) {
[[self proxy] fireEvent:@"touchstart" withObject:event propagate:YES];
}
if ([[self proxy] _hasListeners:@"dblclick"]) {
[[self proxy] fireEvent:@"dblclick" withObject:event propagate:YES];
}
if ([[self proxy] _hasListeners:@"doubletap"]) {
[[self proxy] fireEvent:@"doubletap" withObject:event];
}
}
else {
if ([[self proxy] _hasListeners:@"singletap"]) {
[[self proxy] fireEvent:@"singletap" withObject:event];
}
}
}

-(void)longPressGesture:(UILongPressGestureRecognizer *)recognizer
{
if([[self proxy] _hasListeners:@"longpress"] && [recognizer state] == UIGestureRecognizerStateBegan)
Expand Down