Returning which button was pressed.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tim Mottram
am 26 Okt. 2012
Kommentiert: Sergey Lopatnikov
am 19 Feb. 2017
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 Kommentar
Sergey Lopatnikov
am 19 Feb. 2017
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.
Akzeptierte Antwort
José-Luis
am 26 Okt. 2012
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 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!