Left click works, why doesn't right click?
11 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Kartik
2023 年 3 月 21 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Exploration についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!