Skip to content

[macOS] Add coordinates to Hover events - #4304

Merged
m-bert merged 3 commits into
mainfrom
@mbert/unify-macos-hover
Jul 8, 2026
Merged

[macOS] Add coordinates to Hover events#4304
m-bert merged 3 commits into
mainfrom
@mbert/unify-macos-hover

Conversation

@m-bert

@m-bert m-bert commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Description

I've noticed that on macOS Hover gesture does not provide coordinates, while on other platforms it does. This PR fixes this mismatch.

Test plan

Details
import { View } from 'react-native';
import {
  GestureDetector,
  GestureHandlerRootView,
  useHoverGesture,
} from 'react-native-gesture-handler';

export default function App() {
  const hover = useHoverGesture({
    onBegin: (e) => console.log(e),
  });
  return (
    <GestureHandlerRootView>
      <GestureDetector gesture={hover}>
        <View style={{ width: 100, height: 100, backgroundColor: 'red' }} />
      </GestureDetector>
    </GestureHandlerRootView>
  );
}

Copilot AI review requested due to automatic review settings July 7, 2026 14:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the macOS implementation of Hover so that hover begin/end events include positional data (x/y and absoluteX/absoluteY), bringing macOS behavior in line with iOS and the JS Hover event payload shape.

Changes:

  • Added a macOS helper (extraDataForEvent:) to compute relative and absolute pointer coordinates for hover events.
  • Updated mouseEntered: / mouseExited: to send hover state transitions with the computed position extra data instead of pointerInside.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react-native-gesture-handler/apple/Handlers/RNHoverHandler.m Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@m-bert
m-bert requested a review from j-piasecki July 7, 2026 14:17
@m-bert
m-bert merged commit 8bfaefa into main Jul 8, 2026
4 checks passed
@m-bert
m-bert deleted the @mbert/unify-macos-hover branch July 8, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants