uibuttongroup with no buttons selected?
이전 댓글 표시
I would like to have a uibuttongroup that contains several togglebutton objects. By default, the uibuttongroup obviously only lets you have one toggle button selected (i.e., pressed) at a time. But I would like the possibility to have none of the buttons pressed. I don't see an obvious way to do that using a uibuttongroup. I fear I'll have to just create the toggle buttons and write the logic that controls the states of the buttons myself.
For example, look at the way the default toolbar works in a matlab figure. There are several buttons (rotate, data cursor, etc), and you can't have more than one pressed at a single time, but you can have none of them selected. Any ideas would be much appreciated!
Thanks, Justin
댓글 수: 4
Adam
2016년 4월 29일
It isn't possible as far as I am aware within a button group as the purpose there is to have exactly one selection.
You could add another radio button option to represent that - e.g. Viewing states: 'None', 'Zoom', 'Pan', etc, but it is a bit ugly. I guess toggle buttons are more used for that kind of thing (as in the menu example you give) rather than radio buttons though I guess they have to program the mutual exclusivity behaviour there.
Matthew Eicholtz
2016년 4월 29일
Unfortunately, I think uibuttongroup was designed to act as a "choose one of these options and one must always be selected" kind of tool.
"I fear I'll have to just create the toggle buttons and write the logic that controls the states of the buttons myself."
Why is this a fear? This does not add that much complexity, and I think it is how many built-in MATLAB GUIs are programmed. For example, the "Zoom and Pan" section of the Image Segmenter app uses three toggle buttons as opposed to a button group.
Justin Solomon
2016년 4월 29일
Adam
2016년 4월 29일
You can't deselect a radio button though, it isn't like a toggle button so you could never get back into the nothing selected state even if you could initialise that way.
답변 (1개)
Walter Roberson
2016년 4월 29일
2 개 추천
Create one additional button and set its visible property off, and make it the initially selected button.
댓글 수: 2
Justin Solomon
2016년 4월 30일
편집: Justin Solomon
2016년 4월 30일
Walter Roberson
2016년 4월 30일
You could make that extra button visible and label it as "None" or something similar.
uibuttongroup can also manage toggle buttons; you might want to experiment with that.
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!