Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit b48d8cb

Browse files
committed
fix: "pointerEvents" prop
1 parent d9d6c4c commit b48d8cb

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

React/Views/RCTView.m

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,6 @@ - (BOOL)wantsDefaultClipping
180180
return self.clipsToBounds;
181181
}
182182

183-
- (void)setPointerEvents:(RCTPointerEvents)pointerEvents
184-
{
185-
NSLog(@" setPointerEvents is not implemented");
186-
_pointerEvents = pointerEvents;
187-
188-
// self.userInteractionEnabled = (pointerEvents != RCTPointerEventsNone);
189-
// if (pointerEvents == RCTPointerEventsBoxNone) {
190-
// self.accessibilityViewIsModal = NO;
191-
// }
192-
}
193-
194183
- (void)setTransform:(CATransform3D)transform
195184
{
196185
_transform = transform;
@@ -199,21 +188,15 @@ - (void)setTransform:(CATransform3D)transform
199188

200189
- (NSView *)hitTest:(CGPoint)point
201190
{
202-
// TODO: implement "isUserInteractionEnabled"
203-
// BOOL canReceiveTouchEvents = ([self isUserInteractionEnabled] && ![self isHidden]);
204-
// if(!canReceiveTouchEvents) {
205-
// return nil;
206-
// }
207-
208-
if (self.isHidden) {
191+
if (self.isHidden || _pointerEvents == RCTPointerEventsNone) {
209192
return nil;
210193
}
211194

212195
// `hitSubview` is the topmost subview which was hit. The hit point can
213196
// be outside the bounds of `view` (e.g., if -clipsToBounds is NO).
214197
NSView *hitSubview = nil;
215198
BOOL isPointInside = [self pointInside:point];
216-
BOOL needsHitSubview = !(_pointerEvents == RCTPointerEventsNone || _pointerEvents == RCTPointerEventsBoxOnly);
199+
BOOL needsHitSubview = _pointerEvents != RCTPointerEventsBoxOnly;
217200
if (needsHitSubview && (![self clipsToBounds] || isPointInside)) {
218201
// Take z-index into account when calculating the touch target.
219202
NSArray<NSView *> *sortedSubviews = [self reactZIndexSortedSubviews];
@@ -236,22 +219,7 @@ - (NSView *)hitTest:(CGPoint)point
236219
}
237220
}
238221

239-
return hitSubview ?: (isPointInside ? self : nil);
240-
241-
// TODO: implement "pointerEvents"
242-
// switch (_pointerEvents) {
243-
// case RCTPointerEventsNone:
244-
// return nil;
245-
// case RCTPointerEventsUnspecified:
246-
// return hitSubview ?: hitView;
247-
// case RCTPointerEventsBoxOnly:
248-
// return hitView;
249-
// case RCTPointerEventsBoxNone:
250-
// return hitSubview;
251-
// default:
252-
// RCTLogError(@"Invalid pointer-events specified %lld on %@", (long long)_pointerEvents, self);
253-
// return hitSubview ?: hitView;
254-
// }
222+
return hitSubview ?: (isPointInside && _pointerEvents != RCTPointerEventsBoxNone ? self : nil);
255223
}
256224

257225
static inline CGRect NSEdgeInsetsInsetRect(CGRect rect, NSEdgeInsets insets) {

0 commit comments

Comments
 (0)