Hi, i have a button group in GUI and whenever i press a button i want one specific button to be automatically selected. how can i do it?
thanks

2 件のコメント

Adam
Adam 2017 年 3 月 29 日
編集済み: Adam 2017 年 3 月 29 日
What do you mean by selected (I assume you mean a radio button or checkbox, not a pushbutton?)? And which button? Why don't you just press the button you want selected rather than a different button?
Jan
Jan 2017 年 3 月 29 日
@Adam: Most likely this is a software for an election machine. ;-)

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

 採用された回答

Jan
Jan 2017 年 3 月 29 日

0 投票

You can set the 'Value' of another GUI element in the callback of the pressed button. This does not trigger the callback of the changed element.
Please post the code of the callback, such that we can suggest matching code more easily.

3 件のコメント

TZ
TZ 2017 年 3 月 30 日
Hi, Thanks, i realized that, the question is how do i do it? say i have a group button containing two fields, apples and cherries, and these are also their tag names so is my the button group tag is uipanel what i have to do is code: set(handles.uipanel, 'Value', 'apples')?
Adam
Adam 2017 年 3 月 30 日
編集済み: Adam 2017 年 3 月 30 日
'SelectedObject' is the property you want, but you need to set it to the object handle, not the tag. Or you can do some stuff with string comparisons and set the 'Value' I guess to 0 or 1 accordingly I guess (or 1 or 2, I've forgotten if radiobuttons index from 0 or 1)
TZ
TZ 2017 年 3 月 30 日
Hi, i found an answer, maybe it will interest the readers. there is a topic in handles.uipanel which is called children, that give the addresses of the buttons inside the panel. what i did was: Currents_pointer = get(handles.pnlView,'Children'); set(handles.pnlView,'SelectedObject',Currents_pointer(2)); i took the addresses from the panel and then set the SelectedObject to get this address and it worked.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

質問済み:

TZ
2017 年 3 月 29 日

コメント済み:

TZ
2017 年 3 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by