How do I terminate "wait" function?

2 次查看(过去 30 天)
Shawn Hong
Shawn Hong 2015-4-13
Hello,
I want to terminate or interrupt "wait" function if user presses a cancel button in a gui fig.
Here's a part of my code.
% create a dragable box
rect_h=imrect(gca, position);
while (flag)
% wait until user decides and confirms the box
rectPos=wait(rect_h);
% do the rest jobs
...
...
end
I use "while(flag)" to run the loop until user presses a cancel button. If the cancel button is pressed, the flag is set to false. But the code still stays at
rectPos=wait(rect_h);
until user double clicks to confirm the rectangle.
Any good way to terminate the wait function and escape the while loop by pressing just one cancel button?
Thank you for your help in advance.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by