Callback in push button doesn't work

조회 수: 1 (최근 30일)
mat
mat 2016년 2월 4일
답변: mat 2016년 2월 9일
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
Ingrid
Ingrid 2016년 2월 4일
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 2016년 2월 4일
I updated the code

댓글을 달려면 로그인하십시오.

채택된 답변

mat
mat 2016년 2월 9일
Seems like drawnow did the trick.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 2월 4일
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
mat
mat 2016년 2월 4일
편집: mat 2016년 2월 4일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by