フィルターのクリア

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

14 ビュー (過去 30 日間)
Liyona Bonakdar
Liyona Bonakdar 2013 年 8 月 19 日
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.

採用された回答

David Sanchez
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

その他の回答 (1 件)

Image Analyst
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.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by