2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
2023-11-07 07:55:48 +00:00
|
|
|
<p>ContextMenu requires a collection of menuitems as its <i>model</i> and the <i>show</i> method needs to be called explicity using an event of the target like <i>contextmenu</i> to display the menu.</p>
|
2023-02-28 08:29:30 +00:00
|
|
|
</DocSectionText>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex md:justify-center">
|
|
|
|
<img alt="Logo" src="https://primefaces.org/cdn/primevue/images/nature/nature2.jpg" class="w-full md:w-[30rem] rounded shadow-lg" @contextmenu="onImageRightClick" aria-haspopup="true" />
|
2023-02-28 08:29:30 +00:00
|
|
|
<ContextMenu ref="menu" :model="items" />
|
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
items: [
|
2023-11-07 07:55:48 +00:00
|
|
|
{ label: 'Copy', icon: 'pi pi-copy' },
|
|
|
|
{ label: 'Rename', icon: 'pi pi-file-edit' }
|
2023-02-28 08:29:30 +00:00
|
|
|
],
|
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
2024-05-20 12:14:38 +00:00
|
|
|
<img alt="Logo" src="/images/nature/nature2.jpg" class="w-full md:w-[30rem] rounded shadow-lg" @contextmenu="onImageRightClick" aria-haspopup="true" />
|
2023-10-15 09:38:39 +00:00
|
|
|
<ContextMenu ref="menu" :model="items" />
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
options: `
|
|
|
|
<template>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex md:justify-center">
|
|
|
|
<img alt="Logo" src="https://primefaces.org/cdn/primevue/images/nature/nature2.jpg" @contextmenu="onImageRightClick" class="w-full md:w-[30rem] rounded shadow-lg" aria-haspopup="true" />
|
2023-02-28 08:29:30 +00:00
|
|
|
<ContextMenu ref="menu" :model="items" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
items: [
|
2023-11-07 07:55:48 +00:00
|
|
|
{ label: 'Copy', icon: 'pi pi-copy' },
|
|
|
|
{ label: 'Rename', icon: 'pi pi-file-edit' }
|
2023-02-28 08:29:30 +00:00
|
|
|
]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onImageRightClick(event) {
|
|
|
|
this.$refs.menu.show(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
composition: `
|
|
|
|
<template>
|
2023-03-28 08:25:57 +00:00
|
|
|
<div class="card">
|
2024-05-20 12:14:38 +00:00
|
|
|
<img alt="Logo" src="https://primefaces.org/cdn/primevue/images/nature/nature2.jpg" @contextmenu="onImageRightClick" class="w-full md:w-[30rem] rounded shadow-lg" aria-haspopup="true" />
|
2023-02-28 08:29:30 +00:00
|
|
|
<ContextMenu ref="menu" :model="items" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
|
|
|
const menu = ref();
|
|
|
|
const items = ref([
|
2023-11-07 07:55:48 +00:00
|
|
|
{ label: 'Copy', icon: 'pi pi-copy' },
|
|
|
|
{ label: 'Rename', icon: 'pi pi-file-edit' }
|
2023-02-28 08:29:30 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
const onImageRightClick = (event) => {
|
|
|
|
menu.value.show(event);
|
|
|
|
};
|
|
|
|
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`
|
2023-02-28 08:29:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onImageRightClick(event) {
|
|
|
|
this.$refs.menu.show(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|