How to set togglebutton by another togglebutton

10 ビュー (過去 30 日間)
Miroslav Jiránek
Miroslav Jiránek 2020 年 4 月 4 日
コメント済み: Miroslav Jiránek 2020 年 4 月 4 日
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

採用された回答

Geoff Hayes
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.
  1 件のコメント
Miroslav Jiránek
Miroslav Jiránek 2020 年 4 月 4 日
it helps. thank you so much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by