• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: nsmatrix question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • RE: nsmatrix question
      • From: "Jonathan E. Jackel" <email@hidden>
References: 
 >nsmatrix question (From: Jeff Childers <email@hidden>)

  • Prev by Date: Apology
  • Next by Date: Re: Wait until task is finished?
  • Previous by thread: Re: nsmatrix question
  • Next by thread: RE: nsmatrix question
  • Index(es):
    • Date
    • Thread