On Feb 23, 2012, at 6:58 AM, William Squires wrote:

>  I have a custom view with an NSBox containing an NSMatrix of button cells 
> (radio buttons) When I created the NSMatrix, I told it I wanted 3 of them, 
> but in the view hierarchy, I can see the NSMatrix under the NSBox, but it has 
> 4 button cells under it, not the three I asked for - Is this an Xcode/IB 
> screw-up, or do NSMatrix's always add one extra element when making a group 
> of radio buttons? Should I delete the matrix and try again? When I vertically 
> resize the matrix, I always see three cells, so I don't think there's one 
> hidden under there.

The third (usually first in the list, however) cell is the cell prototype, as 
every NSMatrix needs a cell prototype. 

>  Also, even though I set the tag for each button cell (the top one is 0, the 
> next one down is 1, etc...), when I connect them to my
> 
> -(IBAction)baseChanged:(id)sender
> {
> int choice = [sender tag];
> switch (choice)
>  {
>  case 0: // number base is 16 - hexadecimal
>          NSLog(@"user chose hexadecimal");
>          ...
>          break;
> 
>  case 1: // number base is 2 - binary
>          NSLog(@"user chose binary");
>          ...
>          break;
> 
>  case 2: // number base is 10 - decimal
>          NSLog(@"user chose decimal");
>          ...
>          break;
>  }
> self.numberBase = choice;
> }
> 
> I always get, "user chose hexadecimal"! :( (all the buttons generate an 
> action, so it's not that...)

Is it not? Have you inspected what the sender object truly is? Maybe it is the 
matrix, and not the cell?

>  Am I supposed to connect the NSMatrix to the action, and not the individual 
> cells? If so, how do I ask for the cell's tag value?

Considering that the sender is the NSMatrix: [[sender selectedCell] tag]

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to