Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GothicChess.Com

macrumors regular
Original poster
Apr 6, 2007
126
0
Philadelphia, PA
I'm just trying to turn off one radio button and turn the other one on when a hit on it occurs. I am NOT using a pre-defined cluster from Interface Builder, just 2 separate radio buttons.

Is there any reason why I can see my dialog box (indicating I made it into the code block) yet the controls do not reflect the fact I hit them?

I must be missing something so elementary it almost defies explanation :)


Code:
#define		kFirstRadioSig		'frad'
#define		KSecondRadioSig		'srad'

#define		kFirstRadio_ID		63
#define		KSecondRadio_ID		64

DialogRef		alert;
DialogItemIndex userItemHit;

ControlID	radio_button_control_ID;
ControlRef	radio_button_control_ref;

GetEventParameter(your_event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &the_command);

switch(the_command.commandID)
{
	case KSecondRadioSig: 
		 /**********************************/
		 /* 1st radio button turns off ... */
		 /**********************************/

		 radio_button_control_ID.signature = kFirstRadioSig;
		 radio_button_control_ID.id = kFirstRadio_ID;
		 GetControlByID(g_drawer_window_with_buttons, &radio_button_control_ID, &radio_button_control_ref);
		 SetControlValue(radio_button_control_ref, 0);
		 
		 /**********************************/
		 /* 2nd radio button turns on  ... */
		 /**********************************/

		 radio_button_control_ID.signature = KSecondRadioSig;
		 radio_button_control_ID.id = KSecondRadio_ID;
		 GetControlByID(g_drawer_window_with_buttons, &radio_button_control_ID, &radio_button_control_ref);
		 SetControlValue(radio_button_control_ref, 1);
		 
		 CreateStandardAlert(kAlertPlainAlert, CFSTR("--- YOU MADE IT HERE ---"), CFSTR("Definitely made it to this part of the code for sure."), NULL, &alert);
		 RunStandardAlert(alert, NULL, &userItemHit);
	break;
}
 

cblackburn

macrumors regular
Jul 5, 2005
158
0
London, UK
Where did the variable g_drawer_window_with_buttons come from. You use it to try and change the radio buttons but you do not use it to create the alert, hence if the problem was here you would get the alerts but not the expected behavior.

Also can you breakpoint on the GetControlByID() function and see if radio_button_control_ID etc are updated to reasonable values i.e. not 0x0 or null.

btw, now might be the time to mention I am a Cocoa programmer so I'm debugging this completely abstractly :p.

Chris
 

GothicChess.Com

macrumors regular
Original poster
Apr 6, 2007
126
0
Philadelphia, PA
Where did the variable g_drawer_window_with_buttons come from. You use it to try and change the radio buttons but you do not use it to create the alert, hence if the problem was here you would get the alerts but not the expected behavior.

Also can you breakpoint on the GetControlByID() function and see if radio_button_control_ID etc are updated to reasonable values i.e. not 0x0 or null.

btw, now might be the time to mention I am a Cocoa programmer so I'm debugging this completely abstractly :p.

Chris

Hi Chris,

I built this with XCode and InterfaceBuilder. So, g_drawer_window_with_buttons is just a name I made up for the window (which is a drawer that slides out of another window) and it is of type WindowRef. The actual resource for the window is in InterfaceBuilder.

The odd thing is, the radio buttons "do their thing" from the code module properly, namely, the code block does what I want when I hit them, its just they don't fill in and indicate that I hit them! In the good-ole-days all you have to do was call SetCtlValue with a data type of ControlHandle but now I am trying to figure out how to do it.
 

cblackburn

macrumors regular
Jul 5, 2005
158
0
London, UK
Could you package up the code as a small independent Xcode project exemplifying the problem. It's really difficult to debug without seeing it :)

Thanks

Chris
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.