Problem with changing visibility of pop-up list

2 vues (au cours des 30 derniers jours)
Adrian Luzniak
Adrian Luzniak le 16 Jan 2021
Commenté : Adrian Luzniak le 16 Jan 2021
The code below is a part of my program. In GUI, there are 4 pop-up lists and the code is used to change their visibility. The first one is always visible. First if sets the next 3 lists invisible, the second sets only last 2 invisible, third one sets last one invisible and fourth one sets all visible.
if strcmp(handles.ws,'Jedna')
set(handles.wsyg2, 'visible', 'off'); %line 392
set(handles.wsyg3, 'visible', 'off');
set(handles.wsyg4, 'visible', 'off');
% Update handles structure
guidata(hObject, handles);
elseif strcmp(handles.ws,'Dwie')
set(handles.wsyg2, 'visible', 'on');
set(handles.wsyg3, 'visible', 'off');
set(handles.wsyg4, 'visible', 'off');
% Update handles structure
guidata(hObject, handles);
elseif strcmp(handles.ws,'Trzy')
set(handles.wsyg2, 'visible', 'on');
set(handles.wsyg3, 'visible', 'on');
set(handles.wsyg4, 'visible', 'off');
% Update handles structure
guidata(hObject, handles);
elseif strcmp(handles.ws,'Cztery')
set(handles.wsyg2, 'visible', 'on');
set(handles.wsyg3, 'visible', 'on');
set(handles.wsyg4, 'visible', 'on');
% Update handles structure
guidata(hObject, handles);
end
The problem is that after, for example, setting all 4 lists visible and choosing values from them, it is impossible to go back: I can't choose to have only one visible. I get this error:
Error using set
Invalid handle
Error in SOI_projekt>ws_Callback (line 392)
set(handles.wsyg2, 'visible', 'off');
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in SOI_projekt (line 43)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)SOI_projekt('ws_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Thanks for help.

Réponses (1)

Jan
Jan le 16 Jan 2021
What is the purpose of:
% Update handles structure
guidata(hObject, handles);
For some unknown reasons the value of handles.wsyg2 has been overwritten or the corresponding object was deleted or replaced. Check this using the debugger:
dbstop if error
Then run the code again until it stops at the error. Now check the value of handles.wsyg2 .
If the corresponding object was deleted, this did not happen in the shown part of the code, but somewhere else.
  1 commentaire
Adrian Luzniak
Adrian Luzniak le 16 Jan 2021
You're right, handles.wsyg2 does not work properly - same goes for 3 and 4.
But, what is the best way to check value of handles.wsyg2? Get function does not work, at least I can't get it to work.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by