FROM : Stephan Ruggiero
DATE : Wed Apr 06 19:03:31 2005
Hi,
if you just have one or two radio buttons I'd suggest not to use
NSMatrix - add a regular Button to your Nib and in the attributes
window set the type to be "radio button".
Now the IBOutlet can set to be a pointer to NSButton:
IBOutlet NSButton *myRadioButton1;
IBOutlet NSButton *myRadioButton1;
In the implementaion, you can access the button state with something
like this (not tested):
if ([myRadioButton1 state]) {
NSLog(@"Button state is \"ON\"!");
// some other stuff
} else {
NSLog(@"Button state is \"OFF\"!");
// some more stuff...
}
to go further you can connect an IBAction to the button to call the
method above, so you can react directly to some button changes
------
You wrote:
I've managed (without using bindings, because I don't have time to read
a twenty page document
to get a radio button working) to get the value of a radio button due
to a click on one
of the set. I did this by the [sender selectedTag] method in the
action method.
However there are times when I want to know the value of a radio button
not just when it
has been clicked. I have tried to set it up the radio button set as
an outlet and then
checking the selectedTag however the variable that I created in my
class is nul
in mycontrolle.h I added:
IBOutlet NSMatrix *myRadioButtons;
then somewere in the program when I wanted the value i
tried
NSLog(@"%@", myRadioButtons); // <<---- printed out (null)
[myRadioButtons selectedTag]; // allways returns 0 of course...
DATE : Wed Apr 06 19:03:31 2005
Hi,
if you just have one or two radio buttons I'd suggest not to use
NSMatrix - add a regular Button to your Nib and in the attributes
window set the type to be "radio button".
Now the IBOutlet can set to be a pointer to NSButton:
IBOutlet NSButton *myRadioButton1;
IBOutlet NSButton *myRadioButton1;
In the implementaion, you can access the button state with something
like this (not tested):
if ([myRadioButton1 state]) {
NSLog(@"Button state is \"ON\"!");
// some other stuff
} else {
NSLog(@"Button state is \"OFF\"!");
// some more stuff...
}
to go further you can connect an IBAction to the button to call the
method above, so you can react directly to some button changes
------
You wrote:
I've managed (without using bindings, because I don't have time to read
a twenty page document
to get a radio button working) to get the value of a radio button due
to a click on one
of the set. I did this by the [sender selectedTag] method in the
action method.
However there are times when I want to know the value of a radio button
not just when it
has been clicked. I have tried to set it up the radio button set as
an outlet and then
checking the selectedTag however the variable that I created in my
class is nul
in mycontrolle.h I added:
IBOutlet NSMatrix *myRadioButtons;
then somewere in the program when I wanted the value i
tried
NSLog(@"%@", myRadioButtons); // <<---- printed out (null)
[myRadioButtons selectedTag]; // allways returns 0 of course...
| Related mails | Author | Date |
|---|---|---|
| Brian O'Brien | Apr 6, 18:19 | |
| Scott Stevenson | Apr 6, 18:23 | |
| Brian O'Brien | Apr 6, 19:01 | |
| Stephan Ruggiero | Apr 6, 19:03 | |
| Shawn Erickson | Apr 6, 19:14 | |
| Ricky Sharp | Apr 6, 19:18 | |
| Brian O'Brien | Apr 6, 19:18 | |
| Dave Rehring | Apr 6, 19:22 | |
| Hamish Allan | Apr 6, 20:00 | |
| Brian O'Brien | Apr 6, 22:45 | |
| Brian O'Brien | Apr 6, 22:55 | |
| Caleb Strockbine | Apr 6, 23:05 |






Cocoa mail archive

