react-native-ios-context-menu icon indicating copy to clipboard operation
react-native-ios-context-menu copied to clipboard

Open a context menu programmatically

Open matheusmichels opened this issue 3 years ago • 2 comments

Hey @dominicstop! I'm really enjoying this library, thanks so much for your work on it! I think one great thing to add would be the ability to open a context menu programmatically/imperatively. The API could be something like this:

const event = await UIContextMenu.open(exampleNodeId, menuConfig)

Or

UIContextMenu.open(exampleNodeId, menuConfig, event => {
   // Handle menu item press event
})

What do you think? 😎

matheusmichels avatar May 11 '22 17:05 matheusmichels

+1

xmflsct avatar Jun 06 '22 14:06 xmflsct

I think a better API would be:

const ref = useRef()

const onPress = () => ref.current?.open()

return <ContextMenuView ref={ref} />

nandorojo avatar Oct 07 '22 23:10 nandorojo

Much needed

pfcodes avatar Nov 01 '22 02:11 pfcodes

iOS does not allow this for context menus, so I think it's worth closing.

nandorojo avatar Oct 11 '23 20:10 nandorojo