Creating a Checkbox depending on another Checkbox [GUI]
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
i have to checkboxes. Since the second checkbox activates an additional action to the first checkbox, it must not be "clickable" until the first checkbox is checked.
-> only two possible scenarios: first checked, or both checked.
Is that possible?
I dont think its necessary, but to be more specific:
The first checkbox creates a 3d plot, and the second one creates and saves an adequate fig-file.
Thanks a lot for helping!
댓글 수: 0
답변 (1개)
Geoff Hayes
2016년 8월 13일
mec123 - suppose that you have two checkboxes, checkbox1 and checkbox2, with the latter being enabled only if checkbox1 is checked. To disable the second one, in the OpeningFcn of your GUI you would do
function myGui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
set(handles.checkbox2,'Enable','off');
Then in the callback for your first checkbox, you would do
function checkbox1_Callback(hObject, eventdata, handles)
if get(hObject,'Value') == 1
set(handles.checkbox2,'Enable','on');
else
set(handles.checkbox2,'Value',0,'Enable','off');
end
If checkbox1 is checked (and so its Value property is set to one) then we enable the other checkbox. Else if checkbox1 is unchecked (and so its Value property is set to zero) then we clear the checked state of checkbox2 and disable it.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!