I am trying to implement a click function that activates when a button is clicked. Additionally, I want to incorporate a double click function on the same element that initiates a different action.
var click = false;
onEvent("image2", "click", function(event) {
click = true;
});
if (click === true) {
setTimeout(function() {
onEvent("image2", "click", function(event) {
setScreen("safeScreen");
console.log("double click");
});
}, 200);
} else {
onEvent("image2", "dblclick", function(event) {
setScreen("safeScreen");
console.log("click");
});
}
This code seems to be erroneous, and I am unsure where to begin fixing it. What mistakes have I made? My goal is to ensure that the single click does not activate when the user performs a double click.