instea/react-native-popup-menu

Does the MenuTrigger has onLongPress prop?

Closed this issue · 14 comments

I see that MenuTrigger has onPress prop, but looks like onLongPress not work here?

no, currently not. but I think you could use custom TriggerTouchableComponent create, which onLongPress as onPress expose.

@sodik82 how can I customize TriggerTouchableComponent create? I looked into the examples but find no clue.

there is none - would be good if you can create one and post here.

however just look

- you need to create react component that accepts onPress (and maybe other styling properties)

I checked the code you mentioned.
Since what I hope to do is to expose a prop onLongPress which is the default props from touchable component of RN, why not just add some lines of code on MenuTrigger.js ?

Just follow the way how onPress works there looks good enough, I guess.
Am I correct?

How would you like to switch press / long press trigger? via some prop?

Prop is one option. But I am thinking if I really need to do that switch.

how would you do "both" at the same time?

Let's say I have a Home view which has an plus "+" button on the right top of the header.
When I tap the "+", it shows a popover menu with some options, like adding item, adding image or something else. But also, for user experience, I want this "+" button has a shortcut for users to get to the adding item view, so here I would want to have a longPress prop to handle the navigation.

So I think THAT SWITCH might not be necessary, just like the reason why text and touchable component have two kinds of onPress, just one option for developers to handle how to present the navigation or any expected requirements.

ok, now I understand. if you want to do menu un-related action on longpress (e.g. navigation), you can use triggerTouchable prop of custom styles (see doc).

What I can find from the doc is that triggerTouchable is in the customStyles of MenuTrigger, how can I use that to do the navigation?

something like

<MenuTrigger customStyles={{ triggerTouchable: { onLongPress: () => console.log('navigate') }}} > 

It worked, thank you.
I suggest this part should be added to the doc, because customStyles just looks like styles, kind of misunderstanding.

well, yeah, it is meant for styling :)

@sodik82
I really Thanks sir,