0

I have an NSMatrix in my code, specifically radio buttons. I would like to create a delegate to post a message when the radio button selection is changed.

Which delegate do I have to use? I have tried the textDidChange Method without any success.. obviously, I have used the [radioButtons setDelegate:self] at the initialization stage of the application.

Thanks

Kevin
  • 1,469
  • 2
  • 19
  • 28

1 Answers1

3

NSMatrix is a subclass of NSControl, so you can use the same target-action paradigm as with any other NSControl such as a push button.

You can set the target and action on the NSMatrix using interface builder (control drag from the matrix to a class) or in code with setTarget: and setAction:. Then, when a cell in the matrix (here, a radio button) is selected, the action method is called, and you can query which radio button was selected with the selectedCell method.

See https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Button/Articles/QueryMatrixButtons.html

Adam Leonard
  • 489
  • 2
  • 5
  • I have created an IBAction and am trying to connect the IBAction method with the radio buttons. However, no connection is being made. Any idea how I can make the connection? Thanks. – Kevin Jul 18 '12 at 08:11
  • You should be able to control drag from the matrix of radio buttons to your class with the IBAction. If that doesn't work, you can also find the `NSMatrix` in the sidebar (probably labeled "Matrix") and control drag from that text to your class. Also, make sure the button cells do not have connections set; otherwise, those actions will override the containing `NSMatrix` action. – Adam Leonard Jul 18 '12 at 08:41