uibuttongroup with no buttons selected?

13 次查看(过去 30 天)
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 个评论
Justin Solomon
Justin Solomon 2016-4-29
Thanks Adam and Matt for your responses. Looks like its best to just do it myself.
@Matt, perhaps "fear" was the wrong word choice. Its not a super complicated problem as you mentioned. I think mild "annoyance" is more what I feel in having to basically re-invent the wheel for a scenario that seems pretty commonplace. I would have expected Mathworks to have this functionality already baked into uibuttongroup.
Adam
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
Walter Roberson 2016-4-29
Create one additional button and set its visible property off, and make it the initially selected button.
  2 个评论
Justin Solomon
Justin Solomon 2016-4-30
编辑:Justin Solomon 2016-4-30
Thats a good idea. Only problem is once the user clicks a button, they will never be able to get back to the initial unchecked state. Of course I could write the selection change callback to handle all theses conditions but as I said above, that's the very thing I was hoping to avoid. Anyways, thanks for the suggestion.
Walter Roberson
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by