Callback in push button doesn't work

1 visualización (últimos 30 días)
mat
mat el 4 de Feb. de 2016
Respondida: mat el 9 de Feb. de 2016
Hey I have a simple if function that I want to start with a GUI pushbutton. It only works when I put uiwait before the if (local function) and the uiresume in in the callback function. In debug mode it works without it. How can I preclude using uiwait?
Matlab function
run GUI.m
global start
while true
uiwait;
if start
...
end
end
My GUI pushbutton callback function:
% --- Executes on button press in pushbuttonstart.
function pushbuttonstart_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonstart (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global start
start=true;
uiresume;
  2 comentarios
Ingrid
Ingrid el 4 de Feb. de 2016
your question is not really clear as the code you past is not a function. Could you give a bit more information and code i.e. the actual pushbutton callback and explain what you are trying to achieve
mat
mat el 4 de Feb. de 2016
I updated the code

Iniciar sesión para comentar.

Respuesta aceptada

mat
mat el 9 de Feb. de 2016
Seems like drawnow did the trick.

Más respuestas (1)

Walter Roberson
Walter Roberson el 4 de Feb. de 2016
If you have code that needs to delay until a button is pushed, then you should put the code itself (or a call to it) into the callback of the pushbutton.
  1 comentario
mat
mat el 4 de Feb. de 2016
Editada: mat el 4 de Feb. de 2016
code should still be running in a while loop, I don't want to have delay. But atm the if function only works when using uiwait.

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps 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