Disabling a Button after pressed - GUI
Show older comments
Im getting this error message for a GUI
Struct contents reference from a non-struct array object.
I have the student use version.
Error in JOSHSPOKER>pushbutton1_Callback (line 84)
set(handles.pushbutton1,'enable','off')
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in JOSHSPOKER (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)JOSHSPOKER('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
This is my code:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%DISABLE!!!
set(handles.pushbutton1,'enable','off')
set(handles.pushbutton1,'visible','off')
[MyCard1, MyCard2, TheirCard1, TheirCard2] = shuffle
Answers (1)
Walter Roberson
on 18 Mar 2016
Somehow, your handles structure is not a handles structure. Either:
- it was never set up properly (e.g., you did not use GUIDE and you did not create it yourself); or
- you have used it before it is set up properly (but it should already have been done by the time any callback can be invoked); or
- it has been corrupted, such as you somewhere call
guidata(hObject,handles)
after handles had been set to a non-structure.
8 Comments
Joshua Wojciechowski
on 20 Mar 2016
Joshua Wojciechowski
on 20 Mar 2016
Walter Roberson
on 20 Mar 2016
We need to see your complete .m file that was written by GUIDE.
Joshua Wojciechowski
on 20 Mar 2016
Edited: Walter Roberson
on 20 Mar 2016
Walter Roberson
on 20 Mar 2016
I guess I will need the .fig as well.
Joshua Wojciechowski
on 20 Mar 2016
Joshua Wojciechowski
on 20 Mar 2016
Joshua Wojciechowski
on 20 Mar 2016
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!