-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Feature Request: OnPress to Context Menu #114
Comments
You can show the menu by using it in menu mode, but the preview won't show. iOS as a platform doesn't support anything other than long press to trigger context previews |
@mpiannucci I am not talking about triggering the context view. I'm talking about just adding a basic What if you want another function to navigate to a FullImageScreen to show the image just if it's tapped quickly. Right now you have to wrap the image with Here is a code example: export const CustomContextMenuWithQuickPress = (props: Props) => {
const { children, onQuickPress } = props
const navigation = useAppNavigation()
const Icons = Platform.select({
ios: {
share: "square.and.arrow.up",
shareOriginal: "arrowshape.turn.up.forward",
delete: "trash",
},
android: {
share: "baseline_share",
delete: "baseline_delete",
},
})
function onButtonOnePressed(l) {
console.log("pressed button one")
}
async function onButtonTwoPressed() {
console.log("pressed button two")
}
return (
<ContextMenu
style={{ backgroundColor: colors.transparent }}
actions={[
{ title: "Export", systemIcon: Icons?.share, disabled: !reelFeel.isExportable },
{
title: "Share original",
systemIcon: Icons?.shareOriginal,
disabled: !reelFeel.sharedMedia.isReshareable,
},
{ title: "Delete", systemIcon: Icons?.delete, destructive: true },
{ title: "Cancel" },
]}
previewBackgroundColor={colors.transparent}
onPress={(e) => { // Possibly change the name of this to be onContextItemPress
switch (e.nativeEvent.index) {
case 0:
onButtonOnePressed()
break
case 1:
onButtonTwoPressed()
break
case 2:
onButtonThreePressed()
break
}
// console.warn(`Pressed ${e.nativeEvent.name} at index ${e.nativeEvent.index}`)
}}
{...props}
>Ï
<TouchableOpacity
onPress={onQuickPress} // This does not open the context menu but adds an extra onPress button for the children
onLongPress={() => {}} // Do this to resolve open issue #60
activeOpacity={1.0}>
{children}
</TouchableOpacity>
</ContextMenu>
)
} Essentially you could have three different
Right now there are quite a few issues (#24, #60) open due to the conflicts between embedding a Touchable inside or outside the context menu component and how the press events start acting weird. This may resolve all of that. |
Yes this API would be great, but I haven't found a way to trigger the context menu view programmatically and the iOS system handles the long press behavior automatically. I'm open to PRs tho. BTW, if you are just looking to show the menu on press (not on long press) then just set |
@mpiannucci Thanks, I didn't see that property, although it is still not quite what I'm looking for. Throw aside opening the context menu, I'm just looking for an extra |
+1, I have TouchableOpacity under ContextMenu and it will lead |
Right now, if you want the context menu to appear, you have to use a
longPress
to get it to pop up. This ultimately results in you needing to add a "Pressable" or "TouchableOpacity" inside the context menu to get a normal "onPress" function for whatever the context is supporting.Would be great to have just a normal "onPress" to capture normal press events.
Thanks,
Chris
The text was updated successfully, but these errors were encountered: