As in version 2.2, you can listen for events with a click of the mouse using rightmodifier (and prevent the default behavior of the event contextmenuusing the preventmodifier ):
<button
@mousedown.right="mousedown"
@mouseup.right="mouseup"
@contextmenu.prevent
>
Click Me
</button>
The violin works here.
If you are not using v2.2 or higher, you can manually check the right mouse click using the whichclick event property :
<button
@mousedown="mousedown"
@mouseup="mouseup"
@contextmenu.prevent
>
Click Me
</button>
methods: {
mousedown(event) {
if (event.which === 3) {
console.log("Right mouse down");
}
},
mouseup(event) {
if (event.which === 3) {
console.log("Right mouse up");
}
}
}
The violin works here.
source
share