Disabling a Button after pressed - GUI
显示 更早的评论
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
回答(1 个)
Walter Roberson
2016-3-18
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 个评论
Joshua Wojciechowski
2016-3-20
Joshua Wojciechowski
2016-3-20
Walter Roberson
2016-3-20
We need to see your complete .m file that was written by GUIDE.
Joshua Wojciechowski
2016-3-20
编辑:Walter Roberson
2016-3-20
Walter Roberson
2016-3-20
I guess I will need the .fig as well.
Joshua Wojciechowski
2016-3-20
Joshua Wojciechowski
2016-3-20
Joshua Wojciechowski
2016-3-20
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!