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

Commit

Permalink
添加eventPenetrationEnabled属性,属性为true时,当响应者为自身时将事件穿透传递(子视图正常响应)
Browse files Browse the repository at this point in the history
  • Loading branch information
Txink committed Aug 9, 2019
1 parent b8ac8fa commit 5f586c3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
13 changes: 11 additions & 2 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;
_userInteractionEnabled = YES;
_eventPenetrationEnabled = NO;
_accessibilityHintContent = nil;
_cancelsTouchesInView = YES;

Expand All @@ -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"]];
Expand Down Expand Up @@ -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]];
}
Expand Down Expand Up @@ -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"]]];
}
Expand Down
3 changes: 3 additions & 0 deletions ios/sdk/WeexSDK/Sources/View/WXView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5f586c3

Please sign in to comment.