Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top