Using a pushbutton in MATLAB GUI as a button to continue?
조회 수: 14 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
David Sanchez
2013년 8월 19일
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
댓글 수: 0
추가 답변 (1개)
Image Analyst
2013년 8월 19일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!