Display 1 message for multiple GUI button press

조회 수: 2 (최근 30일)
chlor thanks
chlor thanks 2016년 8월 16일
답변: Geoff Hayes 2016년 8월 18일
My GUI was made in GUIDE.
I notice that if a user presses a pushbutton(designed to display warning messages) multiple times, GUI will display multiple warning messages.
I am hoping to limit GUI to display only one message for multiple buttonpressing? Until the user presses something else in the GUI (such as editbox, listbox, radiobuttons, etc), then the limitation will be renewed (if this pushbutton is pressed again, it will display one other warning message)
I wonder is there a way to do so? Thank you in advance!

답변 (1개)

Geoff Hayes
Geoff Hayes 2016년 8월 18일
chlor - yes, there are ways to programmatically prevent a warning message from being generated (I'm assuming that your code generates this warning because certain conditions have not yet been fulfilled). You could use set a flag in the pushbutton callback that would prevent the warning message from being set again. But then you would need to unset this flag in all other callbacks... For example,
function pushbutton1_callback(hObject,eventdata,handles)
if isempty(handles,'showWarning') || handles.showWarning
% display your warning
handles.showWarning = false;
guidata(hObject,handles);
end
Now, in every other callback you would need to clear this flag
function someOther_Callback(hObject,eventdata,handles)
% do stuff
% set flag to show warning
handles.showWarning = true;
guidata(hObject,handles);
The obvious problem with the above is always having to clear the flag in all other callbacks (where necessary).

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by