PDA

View Full Version : Stupid Radio Buttons!


UselessRob
2005.04.21, 04:01 AM
Howdy

I'm using the Interface builder to make a settings screen for my program. It's all working nicely, except for the stupid radio buttons.

You see, I have it in the code to activate/deactivate different sliders, buttons etc depending on the selection of a set of radio buttons. It works, but it seems that when the value fo the radio buttons changes, the first click doesn't work, but the second does.

I'm not sure I'm making any sense. What happens is, you click option 1 and it activates all the option 1 stuff, then you click option 2 and altho the dot moves to option 2 nothing happens. Click option 2 AGAIN, and then the changes take place.

From debugging I've found that BOTH options say they are active when you make a change of selection. But then how do you know which one is truly active? And why does the 2nd click work?

I'm confused and frightened.

Any suggestions?

Thanks in advance!!

Rob.

UselessRob
2005.04.21, 04:03 AM
I should just say that I've tried a few different way to check which is active. I've tried making a connection for each option, then checking [idOption1 state] == NSOnState, and I've also tried just making a connection for the matrix and checking [[idMatrix cellAtRow: 0 column: 0] intValue] but I have the same problem with both.

Thanks!

ThemsAllTook
2005.04.21, 12:18 PM
Instead of querying the radio buttons' state, you'd probably be better off using the action sent by the radio button to set an internal state, and using that for reference. This is what I've always done, and radio buttons in Cocoa have never given me any trouble.

- Alex Diener

UselessRob
2005.04.22, 12:00 AM
Ahh ok. Yeah that's a good idea. Thanks a lot!

Rob.

blobbo
2005.04.22, 10:20 AM
Themsalltook's course of action is a good one.

I agree, that drawing connections between radio buttons and querying their states is not intuitive. I believe it's because they act like buttons when we want them to be a graphical switch statement. I've found the easiest way is to query selectedRow on the NSMatrix that houses them. Only one connection, and all the functionality that you want/need. Still, the button action is more logical.