Borrar filtros
Borrar filtros

Using a pushbutton in MATLAB GUI as a button to continue?

23 visualizaciones (últimos 30 días)
Hi, I have 2 pushbuttons. With one of them I call a specific function. eg: Main_function(...,...,...).
Now within this Main_function at some points I need the user to press continue. (The user has to change some equipment then continue the work) Previously I used input('') and the user should have just push enter or whatever to continue the function.
Right now I want the second pushbutton to do this, but I don't know how.
my idea was to put a loop like this:
push=0
while push==0
puase(0.1);
end and pushing the button change the push=1, but I can't do that.
Note that I have access to the handles in the called function.

Respuesta aceptada

David Sanchez
David Sanchez el 19 de Ag. de 2013
Add a while loop with nothing inside:
while (~push)
% do nothing until push == 1. Push has to be global, it changes when the pushbutton is pushed
end

Más respuestas (1)

Image Analyst
Image Analyst el 19 de Ag. de 2013
I would not do it like either of you. I think the best way, and what I usually see as recommended, is to wrap a call to msgbox in uiwait. Like this:
uiwait(msgbox('Now, change the equipment, then click OK to continue'));
You can do what I do, and that is to make a separate function called msgboxw (in a separate msgboxw.m file somewhere on your path) and then just call that instead of msgbox:
function msgboxw(message)
uiwait(msgbox(message));
To use
msgboxw('Click OK to continue');
Or, to give the user more flexibility,
promptMessage = sprintf('Do you want to Continue processing,\nor Cancel to abort processing?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
return; % or break, if you're in a loop
end
This has the same effect as msgboxw() except that it allows the user to bail out if they want.

Categorías

Más información sobre Dialog Boxes en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by