Preventing uiwait from opening a figure window when none exists
이전 댓글 표시
I'm currently creating a GUI in which operations need to be halted until a user clicks a pushbutton which calls uiresume. Uiwait creates a figure window if none exists, however, and if the user closes this, uiresume is called whether or not the user hits the button. Is there a way to prevent this, or is uiwait/uiresume not the best way of going about this?
Note that there also may be other figure windows open (depending on the user's actions) at the time, and if possible I would like to have whether or not the program resumes dependent solely on the pushbutton.
Thanks in advance!
Evan
채택된 답변
추가 답변 (1개)
Sean de Wolski
2012년 2월 14일
So you're putting a uiwait() on the figure and then you want them to hit the button before closing the figure?
If so, I would set the closerequestfcn of the figure to [] until the button is pushed, in the button's callback change the closerequestfcn to something useful. Example:
H = figure('closereq',[]);
uicontrol('style','push','string','Push me!','callback',{@(src,evt,H)set(H,'closereq',{@(~,~,H)delete(gcf),H}),H});
uiwait(H);
댓글 수: 3
Evan
2012년 2월 14일
Marek Svoboda
2019년 8월 24일
I had almost an identical problem and your solution worked for me - thanks!!!
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!