You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by mo...@apache.org on 2019/04/01 02:42:56 UTC

[incubator-weex] branch master updated: [iOS] Fix custom component receive touch events when root componet has click event.

This is an automated email from the ASF dual-hosted git repository.

moshen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e70910  [iOS] Fix custom component receive touch events when root componet has click event.
     new 010f985  Merge pull request #2257 from sunshl/feature_keepSubComponentEvent
4e70910 is described below

commit 4e7091096a376ac7718ec85a242177bc718da6e9
Author: huanglei.hl <hu...@alibaba-inc.com>
AuthorDate: Thu Mar 28 15:13:28 2019 +0800

    [iOS] Fix custom component receive touch events when root componet has click event.
    
    * bugfix: If a root component has click event, the custom component inside can't receive touch events.
---
 ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h | 2 ++
 ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m      | 1 +
 ios/sdk/WeexSDK/Sources/Model/WXComponent.mm             | 6 ++++++
 3 files changed, 9 insertions(+)

diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
index 3769846..84a3ce4 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
+++ b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
@@ -90,6 +90,8 @@ typedef id (^WXDataBindingBlock)(NSDictionary *data, BOOL *needUpdate);
     UILongPressGestureRecognizer *_longPressGesture;
     UIPanGestureRecognizer *_panGesture;
     
+    BOOL _cancelsTouchesInView;
+    
     BOOL _listenPanStart;
     BOOL _listenPanMove;
     BOOL _listenPanEnd;
diff --git a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
index 2caf2cf..1facd0b 100644
--- a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
+++ b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
@@ -388,6 +388,7 @@ if ([removeEventName isEqualToString:@#eventName1]||[removeEventName isEqualToSt
     if (!_tapGesture) {
         _tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClick:)];
         _tapGesture.delegate = self;
+        _tapGesture.cancelsTouchesInView = _cancelsTouchesInView;
         [self.view addGestureRecognizer:_tapGesture];
     }
 }
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
index 4f97ffc..44e69c5 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
@@ -100,6 +100,7 @@ static BOOL bNeedRemoveEvents = YES;
         _ariaHidden = nil;
         _accessible = nil;
         _accessibilityHintContent = nil;
+        _cancelsTouchesInView = YES;
         
         _async = NO;
         
@@ -152,6 +153,11 @@ static BOOL bNeedRemoveEvents = YES;
             _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);