How to set togglebutton by another togglebutton
5 次查看(过去 30 天)
显示 更早的评论
Hello guys!
I've 3 togglebuttons in one panel and I would like to set each togglebutton so, that if one of the togglebutton is set to 'Max' value, then the other two togglebuttons are going to be in 'Min' value. I was trying to do something like this in tutorials which I've founded on the forum, but it didnt helped a lot. Can you tell me where is the problem? Thank a lot
function TB_low_ZV_Callback(hObject, eventdata, handles)
hustota_ZV_LOW = get(hObject, 'Value');
if hustota_ZV_LOW == get(hObject, 'Max') %if this button is set to 'Max', change button color and set other two buttons to 'Min'
set(handles.TB_low_ZV,'Backgroundcolor','g');
%setting other buttons
set(handles.TB_med_ZV, 'Value', 'Min'); %turn off toggle buton
TB_med_ZV_Callback(handles.TB_med_ZV, eventdata, handles)
set(handles.TB_high_ZV, 'Value', 'Min'); %turn off toggle buton
TB_high_ZV_Callback(handles.TB_high_ZV, eventdata, handles)
else
set(handles.TB_low_ZV,'Backgroundcolor',[0.94, 0.94, 0.94])
end
0 个评论
采纳的回答
Geoff Hayes
2020-4-4
Miroslav - one problem is with the two lines
set(handles.TB_med_ZV, 'Value', 'Min'); %turn off toggle buton
and
set(handles.TB_high_ZV, 'Value', 'Min'); %turn off toggle buton
. If you want to set them to the minimum value for that toggle button, then you would do
set(handles.TB_med_ZV, 'Value', get(handles.TB_med_ZV, 'Min'));
set(handles.TB_high_ZV, 'Value', get(handles.TB_high_ZV,'Min'));
You need to get the min property so that you can set the value to it. Or, just set use the values of 0 (off) or 1 (on) to set the state of the button.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!