guide and waitfor selectionchangefcn

1 回表示 (過去 30 日間)
Leor Greenberger
Leor Greenberger 2011 年 10 月 3 日
Hi. In my GUIDE gui, I have a "RUN" push button, whose callback function runs through a block of conditional statements to check that the entered inputs are valid. For some bad inputs, I generate an error message, but for others, just a warning. (this is done by updating the string of a listbox).
What I would like to do is make visible a panel that asks if the person wishes to ignore the warnings and proceed anyways. This panel has a button group with two push buttons labeled "yes" and "no"
Is there a way at the end of the "RUN" push button callback function to do something like the following:
if ~isempty(warning_msg)
set(handles.warning_panel,'Visible','on')
ignore_warning = warning_buttongroup_SelectionChangeFcn
end
This checks if there are any warning messages, if yes, it makes visible the panel with the question and push button. The 3rd statemenet, however, I don't believe will work. Is there a way I can make it wait until a selectionchange is detected?

採用された回答

Walter Roberson
Walter Roberson 2011 年 10 月 3 日
ignore_warning = false;
if ~isempty(warning_msg)
set(handles.warning_panel,'Visible','on')
waitfor(handles.warning_buttongroup, 'SelectedObject');
if ishandle(handles.warning_buttongroup) %ensure not deleted
whichobject = get(handles.warning_buttongroup, 'SelectedObject');
ignore_warning = strcmp(get(whichObject,'Tag'),'Yes'); %or the like
end
end
  2 件のコメント
Leor Greenberger
Leor Greenberger 2011 年 10 月 3 日
This worked perfectly! I knew I had to use the waitfor function, but I wasn't sure how to make it work. I also knew about the selectedobject property, but didn't think about using the waitfor on that. Oh well. I also just spent an hour trying to figure out why it was still not working even the code looks correct. Problem: I was using push buttons instead of toggle buttons!
Walter Roberson
Walter Roberson 2011 年 10 月 4 日
uibuttongroups aren't supposed to work on push buttons... I'm surprised it didn't complain.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by