How do I terminate "wait" function?

2 views (last 30 days)
Shawn Hong
Shawn Hong on 13 Apr 2015
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.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!