필터 지우기
필터 지우기

Returning which button was pressed.

조회 수: 4 (최근 30일)
Tim Mottram
Tim Mottram 2012년 10월 26일
댓글: Sergey Lopatnikov 2017년 2월 19일
Hi guys, I have been looking for a while but cant seem to find an answer. If i use something like:
waitforbutttonpress
can I return the button which was pressed? for example:
button = waitforbuttonpress
if button == rightMouse
methodOne
elseif button == leftMouse
methodTwo
else
break
end
  댓글 수: 1
Sergey Lopatnikov
Sergey Lopatnikov 2017년 2월 19일
It will not work. You cannot exit from loop this way. You only can start loop as one of the methods, However, if you start loop[ you will not be able to stop evaluation by mouse click because decision is outside the loop.

댓글을 달려면 로그인하십시오.

채택된 답변

José-Luis
José-Luis 2012년 10월 26일
f = figure(1);
click_type=get(f,'SelectionType');
if strcmp(click_type,'normal') %right click
%Do some stuff
elseif strcmp(click_type,'alt') %left click
%Do some other stuff
end
  댓글 수: 4
Tim Mottram
Tim Mottram 2012년 10월 26일
Answered my own question. if you want it to wait you need waitforbuttonpress.
Tim Mottram
Tim Mottram 2012년 10월 26일
This worked perfectly thanks for all your help :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sachin Ganjare
Sachin Ganjare 2012년 10월 26일
  댓글 수: 1
Tim Mottram
Tim Mottram 2012년 10월 26일
Thanks for the help, I'm not using a GUI but I'll have a look and see if I can modify something :).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by