Closed jacoolee closed 5 years ago
Every <View>
has a contextMenu
prop for this.
const contextMenu = [
{ key: 'foo', title: 'Foo' },
{ isSeparator: true },
{ key: 'bar', title: 'Bar' },
]
<View
contextMenu={contextMenu}
onContextMenuItemClick={event => {
console.log(event.nativeEvent)
}} />
Here is the source code: https://github.com/ptmt/react-native-macos/blob/77580c1707ff5d31889a3f719ef3bbc13afa5e05/React/Views/RCTViewManager.m#L233-L259 https://github.com/ptmt/react-native-macos/blob/77580c1707ff5d31889a3f719ef3bbc13afa5e05/React/Views/RCTView.m#L730-L738
Also, #228 adds an onContextMenu
prop, in case you want to implement a custom right-click menu.
If you have any ideas on how to improve this API, please open a new issue. Thanks!
🚀 Feature Proposal
on mouse right click
Motivation
it's obvious right click is a critical feature for desktop-oriented apps, so I wonder if it's supported already or can it be supported.
Example
on mouse right click, a context menu would show up.