Creating a Checkbox depending on another Checkbox [GUI]
4 ビュー (過去 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!