Reputation: 313
How can I quit an App designer GUI using a button?
I tried this and it does not work:
function QuitButtonPushed(app, event)
fig = uifigure;
selection = uiconfirm(fig,'Close software?','Quit', 'Icon','warning');
switch selection
case 'Yes'
app.delete;
case 'No'
return
end
Upvotes: 2
Views: 832
Reputation: 32124
The switch case should be with 'OK'
and 'Cancel'
and not 'Yes'
, 'No'
.
It is also recommended to pass app.UIFigure
instead of using fig = uifigure;
:
selection = uiconfirm(app.UIFigure,'Close software?','Quit', 'Icon','warning');
switch selection
case 'OK'
app.delete();
case 'Cancel'
return
end
Upvotes: 1