I am new to webdevelopment and I am dealing problems with vue. From tutorial I learned that it is possible to use @click when button is pressed. It works fine.
Now I want to make simple measurement that mouse is down and up for further development of double-click and long press detector (I also found out that it is possible to use @double-click but due to unknown reason it is also not working). Can you please explain me what I am doing wrong?
NOTE: I know that there are many packages which deals it but I want to keep it simple if possible.
<script>
export default {
data() {
return {
counter: 0,
}
},
methods: {
greet(event) {
this.counter = 2
}
}
}
</script>
<template>
<button @mouse-down="greet">Greet {{ counter }}</button>
</template>
>Solution :
The event name is "@mousedown" not "@mouse-down"
<button @mousedown="greet">Greet {{ counter }}</button>
But be careful with this event. It handles all mouse buttons (left, middle, right) and called when you downed any of these buttons.
To handle only one button down event you should to use ".left" or ".right" modifier.
For example:
<button @mousedown.left="greet">Greet {{ counter }}</button>
It will handle only when left button downed.