Problem with changing visibility of pop-up list

조회 수: 2 (최근 30일)
Adrian Luzniak
Adrian Luzniak 2021년 1월 16일
댓글: Adrian Luzniak 2021년 1월 16일
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.

답변 (1개)

Jan
Jan 2021년 1월 16일
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
Adrian Luzniak
Adrian Luzniak 2021년 1월 16일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by