Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] Fix custom component receive touch events when root componet ha…
Browse files Browse the repository at this point in the history
…s click event.

* bugfix: If a root component has click event, the custom component inside can't receive touch events.
  • Loading branch information
huanglei.hl committed Mar 28, 2019
1 parent 36dce32 commit 4e70910
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ typedef id (^WXDataBindingBlock)(NSDictionary *data, BOOL *needUpdate);
UILongPressGestureRecognizer *_longPressGesture;
UIPanGestureRecognizer *_panGesture;

BOOL _cancelsTouchesInView;

BOOL _listenPanStart;
BOOL _listenPanMove;
BOOL _listenPanEnd;
Expand Down
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ - (void)addClickEvent
if (!_tapGesture) {
_tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClick:)];
_tapGesture.delegate = self;
_tapGesture.cancelsTouchesInView = _cancelsTouchesInView;
[self.view addGestureRecognizer:_tapGesture];
}
}
Expand Down
6 changes: 6 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ - (instancetype)initWithRef:(NSString *)ref
_ariaHidden = nil;
_accessible = nil;
_accessibilityHintContent = nil;
_cancelsTouchesInView = YES;

_async = NO;

Expand Down Expand Up @@ -152,6 +153,11 @@ - (instancetype)initWithRef:(NSString *)ref
_customEvent = [WXConvert BOOL:attributes[@"customEvent"]];
}

if (attributes[@"cancelsTouchesInView"]) {
_cancelsTouchesInView = [WXConvert BOOL:attributes[@"cancelsTouchesInView"]];
}


#ifdef DEBUG
WXLogDebug(@"flexLayout -> init component: ref : %@ , styles: %@",ref,styles);
WXLogDebug(@"flexLayout -> init component: ref : %@ , attributes: %@",ref,attributes);
Expand Down

0 comments on commit 4e70910

Please sign in to comment.