简体   繁体   中英

NSMatrix delegate

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM