Which checkboxes are selected in MATLAB GUI? - matlab

When I want to know which radio buttons are selected in a panel in a MATLAB GUI, I use this line:
ChosenOption = get(handles.OptionPanel, 'SelectedObject');
where OptionPanel is the Tag of the panel where the radio buttons are located.
However, if I want to use checkboxes instead of radio buttons, is there any way to do the same?
Thank you.

You would typically get the Value property of each checkbox to determine whether it was checked or not.
Note that typically with checkboxes any, all, or none of the checkboxes may be selected (in contrast to radio buttons, where typically only a single radio button would be selected at any one time), so you would want to get the Value property of each checkbox separately. There's no equivalent of a uibuttongroup that you would use with radio buttons (although you can of course graphically group the checkboxes in a uipanel).

Related

Disable radio buttons contained in Box

I have a set of radio buttons that are placed within a box.
When the user selects an option, these buttons needs to be disabled. I cannot find a relevant property to disable all items within the box.Only option I can find is to set the hidden property.
box.isHidden=true
NSButton inherts from NSControl, which has an isEnabled property. If you want your radio buttons to still be visible but not clickable, use that.

Option Button hook in ClearQuest

I'm trying to set a text field to display text when a group of two option buttons is set to Yes. (They are Yes and No radio buttons). I have them set so when checked, the value is 1.
When Yes is selected, text is supposed to be visible in the text field. When No is selected, I would like for the field to be blank.
Right now, when I run the test database, check Yes, and save the radio button looks like it's saving the Yes, but then reverts to having No checked.
I'm writing my hook in Perl. So far I have this in the Value Changed hook for the Yes radio button:
my $checked = $entity->GetFieldValue($fieldname)->GetValue();
if($checked eq "1"){
my $setCharge = " This text when check Yes!";
$entity->SetFieldValue("name_of_text_field", $setCharge);
}
the radio buttons are both SHORT_STRING as is probably evident by my string comparison.
I've tried setting the other radio button to 0 just to make sure it's not checked, but that seems redundant since only one radio button can be selected. I've tried writing a hook for the no Value Changed, but that didn't work either.
Ideas?

Radio Button matrix with GWT

I would like to create a radio button matrix with GWT. Only one radio button should be selected in each row and in each column.
The think is, with GWT, a radio button cannot belong to two different RadioGroups.
Do you have any ideas how i can implement this radio button matrix?
Thanks.
I think of two ways of doing that:
1)you can try the checkboxes and include if/else statements so as to allow only one radio button from each row to be selected.
2)possibly working with composites.
3) See this example with Ext-GWT: http://www.java2s.com/Code/Java/GWT/UsingRadioGrouptogroupRedioButtonsExtGWT.htm

Is there a way to uncheck all radio buttons in a group? (PyGTK)

Is there a way to uncheck all radio buttons in a group with PyGTK? No radio buttons are checked on startup, so I think there must be a way to return them all to that unchecked state.
I agree with Michael, but for the record this can be done.
One way to do this would be to have a hidden radio button that you could activate, which would then cause all the visible ones to be inactive. Quick n' Dirty example:
import gtk
window = gtk.Window()
window.set_default_size(200, 200)
rb1 = gtk.RadioButton()
rb2 = gtk.RadioButton()
rb3 = gtk.RadioButton()
rb2.set_group(rb1)
rb3.set_group(rb2)
rb3.set_active(True)
hbox = gtk.HBox()
hbox.add(rb1)
hbox.add(rb2)
hbox.add(rb3)
button = gtk.Button("Click me")
button.connect("clicked", lambda x: rb3.set_active(True))
hbox.add(button)
window.add(hbox)
window.show_all()
rb3.hide()
gtk.main()
There shouldn't be. By their nature, a radio button group is a 'pick one of many' type of control. From a human perspective, the idea is that one of them is always selected. The framework really should enforce that, so there really shouldn't be a 'none selected' state for the group. The none-selected state of a radio button group (in frameworks where it's possible) is very confusing to users, because that's not a state that they can get the control into.
If you want a 'none selected' state, I'd say you should add a 'none' element to the group, OR chose a different control type that conforms to what you want to do with it.
Looked it up in the source code and set_active simply simulates a click on the button if the new state is different from the old one. The radio button code then checks to see if there is another radio button in the group active and if not, it refuses to change as you noticed.
From what it looks the first radio button should always be set to active when you create the group (as expected). If it doesn't show it is likely a bug, it would be interested to see if radio_button.get_active is True for the first button you create (even if it doesn't show up in the UI).
I agree with Michael Kohne though that you should look into another UI element if you want to make all the radio buttons unselected.
My solution, which is notably not encouraged, Is to have a radio button in the same group that isn't shown on screen.
In Glade you can 'add widget as toplevel' in the context menu of the widget add button. In code I would imaging it's basically just don't add the widget to any displayed gui, or carefully don't .show() it (including .showall() on a parent)

Dynamic GWT Menu

How can I modify a GWT menu - grey out some entries, put a checkmark next to others, according to my application state?
My app has a menu bar across the top - File, Edit, View, Insert, Format, etc. I have a number of paragraphs, each of which could have a different format. When the user clicks on Format, I want the format menu to show a checkmark next to the menuItem that corresponds to the format of the currently selected paragraph. If some formats are inappropriate for the currently selected paragraph, I want to grey those menuItems out.
The main issue is when to do the update: (a) when the Format menu button is clicked, or (b) each time my user selects a new paragraph?
I find option (a) more appealing. But how can I detect this? A MenuItem doesn't have any facility for adding event listeners. It could be a mouseClick that I need, but it might be a mouseOver: if the user clicks on the Insert menuItem the Insert menu will appear, but then if the mouse is moved over Format, then the Format menu will appear.
Option (b) sounds simpler, but wastes more processor time.
For my contextMenu (right click on the paragraph), it's much easier, because the menu is only constructed when the right click happens.
I've resorted to using the square-root symbol (&#8730) for a tick. Does anyone know a nicer way? Do I need to use HTML and use " Plain-Format" for my menu item?
Finally, is there a way to disable (grey-out) a menu item so that it can't be selected?
Option (a) sounds better from a conserving resources point of view.
Instead of using the square-root symbol, why don't you use an image (using the com.google.gwt.user.client.ui.Image class)?
I think a more elegant/simple solution might be to use the checkbox class for your menu items. That way you could have automatic ticks/checks instead of having to use an image or the square-root symbol. Also, you will be able to "grey-out" items with setEnabled(false). Otherwise, you will have to write your own widget or add your own functionality to your menu labels in order to "grey-out" items.