Re: nsmatrix question
Re: nsmatrix question
- Subject: Re: nsmatrix question
- From: Neil Earnshaw <email@hidden>
- Date: Tue, 24 Jun 2003 22:47:11 +0100
On Tuesday, June 24, 2003, at 03:30 PM, Jeff Childers wrote:
I have a nsmatrix of buttons. when a button in the matrix is clicked I
want to know the row and column of the button.
I thought it might be:
//floorMatrix is the outlet for matrix
[[floorMatrix selectedCell] getRow:(int *)row column:(int *)column
ofCell:(NSCell *) sender];
any help or leads would be useful
The Calculator example in Building Cocoa Applications, published by
O'Reilly, has an array of buttons to represent the digits 0-9. When
they are pressed an (IBAction)enterDigit:(id)sender message is sent to
the controller class. it then uses this expression
[[sender selectedCell] tag]
to get the integer 'tag' value that has been assigned to each button in
IB. The '0' button has the tag value 0, etc. You'll find a tag field
at the bottom of the Attributes Inspector page when you've selected a a
button cell in IB. Enter a value there and detect it in your IB action.
Alternatively, if you don't want to use tags, you can get hold of
[sender selectedCell] and iterate over the rows and columns of the
matrix calling [floorMatrix cellAtRow:r column:c] until you find a
match.
-Neil
Neil Earnshaw
Consultant Software Engineer
Object Software Engineers Ltd
email@hidden
Tel : 01747 854 852
Mbl : 07870 209 102
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.