Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MacOS] Fix Pressable being unresponsive #3142

Merged
merged 6 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apple/RNGestureHandlerPointerTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ - (int)registeredTouchesCount
- (NSDictionary *)extractPointerData:(int)index forTouch:(RNGHUITouch *)touch
{
#if TARGET_OS_OSX
CGPoint absolutePos = [touch locationInWindow];
CGPoint relativePos = [touch.window.contentView convertPoint:absolutePos fromView:_gestureHandler.recognizer.view];
CGFloat windowHeight = touch.window.contentView.frame.size.height;
CGPoint yFlippedAbsolutePos = [touch locationInWindow];
CGPoint absolutePos = CGPointMake(yFlippedAbsolutePos.x, windowHeight - yFlippedAbsolutePos.y);
CGPoint relativePos = [_gestureHandler.recognizer.view convertPoint:absolutePos fromView:touch.window.contentView];
#else
CGPoint relativePos = [touch locationInView:_gestureHandler.recognizer.view];
CGPoint absolutePos = [touch locationInView:_gestureHandler.recognizer.view.window];
Expand Down
8 changes: 4 additions & 4 deletions src/components/Pressable/Pressable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export default function Pressable(props: PressableProps) {
Gesture.Native()
.onBegin(() => {
// Android sets BEGAN state on press down
if (Platform.OS === 'android') {
if (Platform.OS === 'android' || Platform.OS === 'macos') {
isTouchPropagationAllowed.current = true;
}
})
Expand Down Expand Up @@ -358,10 +358,10 @@ export default function Pressable(props: PressableProps) {
gesture.enabled(isPressableEnabled);
gesture.runOnJS(true);
gesture.hitSlop(appliedHitSlop);
gesture.shouldCancelWhenOutside(false);
gesture.shouldCancelWhenOutside(true);
m-bert marked this conversation as resolved.
Show resolved Hide resolved

if (Platform.OS !== 'web') {
gesture.shouldCancelWhenOutside(true);
if (Platform.OS === 'web') {
gesture.shouldCancelWhenOutside(false);
m-bert marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading