I am writing a program in which at some point a graph is plotted and displayed on screen. The user then needs to press \'y\' or \'n\' to accept or reject the graph. My current s
You don't want to use waitforbuttonpress
since it locks the figure gui (no zooming, panning etc).
pause
can cause the command window to steal the focus from the figure.
The solution I find to work best is to open the figure with a null keyPressFcn in order to avoid focus problems:
figure('KeyPressFcn',@(obj,evt) 0);
and then wait for CurrentCharacter property change:
waitfor(gcf,'CurrentCharacter');
curChar=uint8(get(gcf,'CurrentCharacter'));