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

Additional fix for #199 #206

Merged
merged 1 commit into from
May 3, 2013
Merged
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
Touch compatibility fix
  • Loading branch information
ohanslik-vendavo committed May 3, 2013
commit f6b06e4c97d9259281affa6924bf0e493934132e
40 changes: 35 additions & 5 deletions src/UIView+PublicAutomation.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,42 @@ - (BOOL)FEX_canTouchPoint:(CGPoint)point {

UIView* touchedView = [self.window hitTest:pointInWindowCoords withEvent:nil];

while (touchedView != nil) {
if (touchedView == self) {
return YES;
}
if ([touchedView isDescendantOfView:self]) {
return YES;
}
else if ([self isDescendantOfView:touchedView]) {
/* the following code implements the same functionality as `hitTest:withEvent:`
but it doesn't ignore views with disabled user interactions */

BOOL canContinue;

touchedView = touchedView.superview;
do {
canContinue = NO;

CGPoint testedPoint = [self.window convertPoint:pointInWindowCoords toView:touchedView];
NSArray* subviews = [[touchedView.subviews copy] autorelease];

for (NSUInteger i = subviews.count; i > 0; i--) {
UIView* subview = [subviews objectAtIndex:(i - 1)];

if (subview.alpha < 0.01 || subview.hidden) {
continue;
}

CGPoint testedPointInSubviewCoords = [subview convertPoint:testedPoint fromView:touchedView];

if ([subview pointInside:testedPointInSubviewCoords withEvent:nil]) {
if (subview == self) {
return YES;
}
else {
touchedView = subview;
canContinue = YES;
break;
}
}
}
} while (canContinue);
}

return NO;
Expand Down