Left click works, why doesn't right click?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
When i run this code if i left click, a line will be drawn where i want it to be, but if i right click it will respond as though I have left clicked.
It is essentially the same function with just a right click instead of a left.
-Also this function requires me to double click, when i have the statement
while button ==1
-> is this normal?
Here is the entireity of the code:
0 commentaires
Réponses (1)
Kartik
le 21 Mar 2023
Hi,
The issue with the right-click event can be due to the fact that in the while loop condition, you are checking if 'button == 3' for detecting user 2 input, but in the 'ginput()' function, the right-click button is usually assigned the value '2', and the left-click button is assigned the value '1'. Therefore, you should change the condition in the second while loop to 'button == 2' instead of 'button == 3'.
Regarding the double-click issue, it seems to be normal because the 'ginput()' function waits for user input and the while loop runs continuously until the user presses a button. Therefore, if the user presses and releases the button quickly, the function may detect it as a double-click event. However, to avoid this, you can add a small delay or a pause() function call inside the while loop to give the user some time to release the button before detecting the next click.
0 commentaires
Voir également
Catégories
En savoir plus sur Data Exploration dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!