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

Adding handling for different Mouse Buttons to Pressable like Middle Mouse Button #831

Open
Amir-A-M opened this issue Nov 24, 2024 · 0 comments

Comments

@Amir-A-M
Copy link

Hello

Wouldn't it be good to have the ability to determine more events for web?

Like for Pressable if the Platform.OS === 'web' onPress event returned a value containing the key
Like

const onPressHandler = (e) => {
  if(Platform.OS === 'web' && e.key === 'Middle Mouse Button' ) {
   // do something...
  }
}

<Pressable
  onPress={onPressHandler}
/>

my specific use case was to use Pressable from react-native-gesture-handler instead of Link so items wouldn't get dragged by mouse in a carousel in web. but be able to open links in new tab. but there was no Middle Mouse Button handler
I finally used

Platform.OS === 'web' ? (
<a
  href={item.url}
  className='select-none [user-drag:none]'
  draggable='false'
>
) : 
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

No branches or pull requests

1 participant