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

Support double tap to open (or ref/manual open)

Open tsalama opened this issue 2 years ago • 10 comments

Hello,

Thanks a lot for this library, it's been a pleasure to use.

With that, I'd like to request support for a doubleTapToOpen prop or something similar to support opening the context menu using a double tap similar to iMessage/WhatsApp.

If over-complicated, it would be great to at least have support for a ref that allows us to manually trigger the menu to open and write the double tap logic ourselves.

Thank you!

tsalama avatar Mar 22 '23 00:03 tsalama

@mpiannucci Hey man, thanks for the library. Just curious if you have any ideas for this one. Would be awesome to be able to have a ref.triggerContextMenu() or something along those lines!

Thanks again.

tsalama avatar Apr 03 '23 18:04 tsalama

Let me look into it. It's probably possible on android but not sure if the api on iOS. Added to my list

mpiannucci avatar Apr 04 '23 00:04 mpiannucci

Heyo - this is pretty dope, I think it's possible on iOS! The react-native-context-menu lib from dominic also has this - but I think this lib is cleaner, would be cool to also have that option here.

mrousavy avatar Nov 23 '23 19:11 mrousavy

Yeah I like exposing the method to open and the double tap. I'll try and take a stab this weekend :)

mpiannucci avatar Nov 23 '23 20:11 mpiannucci

king 👑

mrousavy avatar Nov 23 '23 21:11 mrousavy

So it is not supported by iOS directly to trigger the menu programmatically, as I feared. Can be hacked around tho probs

mpiannucci avatar Nov 23 '23 22:11 mpiannucci

Kind of a hack, but a simple solution is using event propagation to limit the event tracking of the context menu from the child.

https://react.dev/learn/responding-to-events#stopping-propagation

The other library does some crazy logic to have this functionality and I'm not sure I want to introduce the same amount of complexity. This libraries biggest strength is its simplicity to me.

mpiannucci avatar Nov 24 '23 03:11 mpiannucci

Yea I understand that motivation, let's keep it simple! :) thanks

mrousavy avatar Nov 24 '23 09:11 mrousavy