Left click works, why doesn't right click?
조회 수: 7 (최근 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!