Using uiwait with wrndlg with modal property in a guide callback of a slider throws the code into chaos

2 vues (au cours des 30 derniers jours)
Hello, In the callback of my slider which I created using guide, I want to insert a warndlg once a particular value has exceeded. I want to stop interaction with the main figure till the wrndlg box has been acknolwedged. I do so as: call a function which gives me an errorvalue 1 or 0 is the limit has exceeded.
function sliderElec1_Callback(hObject, eventdata, handles)
% hObject handle to sliderElec1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
[errorValue,errorMsg] = checkStimulationPara(hObject,handles);
if errorValue
uiwait(warndlg(errorMsg, 'Warning', 'modal'));
fid = fopen(handles.errorFileName,'at');
fprintf(fid,[datestr(now,'yymmdd') ' ' datestr(now,'HHMM'),': ']);
fprintf(fid,['checkStimulationfn', '', errorMsg,'\n']);
fclose(fid);
end
now, when i slide the slider across the set value for eg: 30, the dlg box goes crazy, opens and closes multiple times and goes into an infinte loop by increasing the slider value.
Any help will be greatly appreciated!
  14 commentaires
Adam
Adam le 15 Août 2018
If you are using a standard Matlab slider with a release callback rather than a continuous callback then it probably shouldn't cause problems, but it is something I always avoid doing as it is easy to create problems for yourself by 'pulling the rug out from under your feet'
Darshan Shah
Darshan Shah le 15 Août 2018
I had no idea there were these variations! Thank you for pointing it out!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by