From 5f586c3d7977c132647e7307648b85bef2233871 Mon Sep 17 00:00:00 2001 From: Txink <1256065080@qq.com> Date: Fri, 9 Aug 2019 12:50:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0eventPenetrationEnabled?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=EF=BC=8C=E5=B1=9E=E6=80=A7=E4=B8=BAtrue?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=BD=93=E5=93=8D=E5=BA=94=E8=80=85=E4=B8=BA?= =?UTF-8?q?=E8=87=AA=E8=BA=AB=E6=97=B6=E5=B0=86=E4=BA=8B=E4=BB=B6=E7=A9=BF?= =?UTF-8?q?=E9=80=8F=E4=BC=A0=E9=80=92=EF=BC=88=E5=AD=90=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E5=93=8D=E5=BA=94=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Component/WXComponent_internal.h | 3 ++- ios/sdk/WeexSDK/Sources/Model/WXComponent.mm | 13 +++++++++++-- ios/sdk/WeexSDK/Sources/View/WXView.m | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h index 0aeaa0f051..c58a7967d5 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h +++ b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h @@ -71,7 +71,8 @@ typedef id (^WXDataBindingBlock)(NSDictionary *data, BOOL *needUpdate); NSString * _groupAccessibilityChildren; // voice-over navigation order NSString * _testId;// just for auto-test - BOOL _userInteractionEnabled; + BOOL _userInteractionEnabled; + BOOL _eventPenetrationEnabled; BOOL _accessibilityMagicTapEvent; /** diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm index 0454aaff29..0576655665 100644 --- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm +++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm @@ -100,6 +100,7 @@ - (instancetype)initWithRef:(NSString *)ref _ariaHidden = nil; _accessible = nil; _userInteractionEnabled = YES; + _eventPenetrationEnabled = NO; _accessibilityHintContent = nil; _cancelsTouchesInView = YES; @@ -124,6 +125,10 @@ - (instancetype)initWithRef:(NSString *)ref _userInteractionEnabled = [WXConvert BOOL:attributes[@"userInteractionEnabled"]]; } + if (attributes[@"eventPenetrationEnabled"]) { + _eventPenetrationEnabled = [WXConvert BOOL:attributes[@"eventPenetrationEnabled"]]; + } + if (attributes[@"ariaHidden"]) { _ariaHidden = [WXConvert NSString:attributes[@"ariaHidden"]]; @@ -405,9 +410,9 @@ - (UIView *)view _view.wx_component = self; _view.wx_ref = self.ref; _layer.wx_component = self; - + [_view setUserInteractionEnabled:_userInteractionEnabled]; - + if (_roles) { [_view setAccessibilityTraits:[self _parseAccessibilityTraitsWithTraits:self.view.accessibilityTraits roles:_roles]]; } @@ -891,6 +896,10 @@ - (void)_configWXComponentA11yWithAttributes:(NSDictionary *)attributes [self.view setUserInteractionEnabled:_userInteractionEnabled]; } + if (attributes[@"eventPenetrationEnabled"]) { + _eventPenetrationEnabled = [WXConvert BOOL:attributes[@"eventPenetrationEnabled"]]; + } + if (attributes[@"testId"]) { [self.view setAccessibilityIdentifier:[WXConvert NSString:attributes[@"testId"]]]; } diff --git a/ios/sdk/WeexSDK/Sources/View/WXView.m b/ios/sdk/WeexSDK/Sources/View/WXView.m index 5e099c3a34..29b4cd1766 100644 --- a/ios/sdk/WeexSDK/Sources/View/WXView.m +++ b/ios/sdk/WeexSDK/Sources/View/WXView.m @@ -40,6 +40,9 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event UIView* result = [super hitTest:point withEvent:event]; if (result) { + if (self.wx_component->_eventPenetrationEnabled && result == self) { + return nil; + } return result; }