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-18545] Check interactionEnabled conditionally #6630

Merged
merged 1 commit into from
Feb 10, 2015
Merged
Changes from all commits
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
19 changes: 17 additions & 2 deletions iphone/Classes/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#define IGNORE_IF_NOT_OPENED if (!windowOpened||[self viewAttached]==NO) return;

static NSArray* touchEventsArray;

@implementation TiViewProxy

@synthesize eventOverrideDelegate = eventOverrideDelegate;
Expand Down Expand Up @@ -1536,6 +1538,17 @@ -(BOOL)_hasListeners:(NSString *)type
return [self _hasListeners:type checkParent:YES];
}

-(BOOL)checkTouchEvent:(NSString*)event
{
if (touchEventsArray == nil) {
touchEventsArray = [[NSArray arrayWithObjects:@"touchstart",@"touchend",@"touchmove",@"touchcancel",
@"click",@"dblclick",@"singletap",@"doubletap",@"twofingertap",
@"swipe", @"pinch", @"longpress", nil] retain];
}

return [touchEventsArray containsObject:event];
}

//TODO: Remove once we've properly deprecated.
-(void)fireEvent:(NSString*)type withObject:(id)obj withSource:(id)source propagate:(BOOL)propagate reportSuccess:(BOOL)report errorCode:(int)code message:(NSString*)message;
{
Expand All @@ -1550,7 +1563,8 @@ -(void)fireEvent:(NSString*)type withObject:(id)obj withSource:(id)source propag
// Have to handle the situation in which the proxy's view might be nil... like, for example,
// with table rows. Automagically assume any nil view we're firing an event for is A-OK.
// NOTE: We want to fire postlayout events on ANY view, even those which do not allow interactions.
if (proxyView == nil || [proxyView interactionEnabled] || [type isEqualToString:@"postlayout"]) {
BOOL isTouchEvent = [self checkTouchEvent:type];
if (proxyView == nil || !isTouchEvent || (isTouchEvent && [proxyView interactionEnabled])) {
[super fireEvent:type withObject:obj withSource:source propagate:propagate reportSuccess:report errorCode:code message:message];
}
}
Expand All @@ -1568,7 +1582,8 @@ -(void)fireEvent:(NSString*)type withObject:(id)obj propagate:(BOOL)propagate re
// Have to handle the situation in which the proxy's view might be nil... like, for example,
// with table rows. Automagically assume any nil view we're firing an event for is A-OK.
// NOTE: We want to fire postlayout events on ANY view, even those which do not allow interactions.
if (proxyView == nil || [proxyView interactionEnabled] || [type isEqualToString:@"postlayout"]) {
BOOL isTouchEvent = [self checkTouchEvent:type];
if (proxyView == nil || !isTouchEvent || (isTouchEvent && [proxyView interactionEnabled])) {
if (eventOverrideDelegate != nil) {
obj = [eventOverrideDelegate overrideEventObject:obj forEvent:type fromViewProxy:self];
}
Expand Down