Preventing uiwait from opening a figure window when none exists
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
Sean de Wolski
le 14 Fév 2012
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 commentaires
Evan
le 14 Fév 2012
Marek Svoboda
le 24 Août 2019
I had almost an identical problem and your solution worked for me - thanks!!!
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!