How to create NSRadioButton Group in Xcode 7 OSX
Asked Answered
W

3

26

I was following this tutorial on how to create radio button group. But it seems Radio Group is no longer available in the Xcode 7 library and I didn't find much information about it. How do I create something like this:

enter image description here

Thanks very much.

Witham answered 28/6, 2015 at 19:43 Comment(4)
Maybe this post can help you.Beaver
Thanks. But this requires 3rd party and it's also for iOS, not OS X...Witham
Thanks. I should have been more careful when reading the introduction. It worked!Witham
All answers do not cover the following change of behavior. In the past, I could bind some controller member to the NSMatrix (or radio-group) selection, and so have a value which is always synchronized with the selected radio button. Now I can't, since they're all individual buttons. I am forced to implement an Action (which I don't really need) for doing this (and for actual grouping of the buttons). How to go about that?Andresandresen
H
31

Quoting from the Xcode 7 release notes:

The template for Radio buttons in the Interface Builder object library is now implemented as individual NSButton objects, rather than the older NSMatrix, which is discouraged on OS X v10.8 and later. Radio buttons automatically act as a group (selecting one button will unselect all other related buttons) when they have the same superview and -action method. (16965941)

So drag individual radio buttons and make sure you connect them all to the same outlet!

Hooligan answered 6/10, 2015 at 1:15 Comment(2)
I'm sure you mean same action, not outlet?Tigerish
@NicolasMiari Yes, it works if you set it as actionCaddy
F
11

This way of doing radio button groups is "soft deprecated", follow what Xcode 7 says when selecting a radio button:

Xcode 7 radio button

Fertile answered 28/6, 2015 at 21:7 Comment(0)
W
5

Thanks to Eric's advice, I went back and placed the radio buttons in the same superview and it worked. enter image description here

Witham answered 28/6, 2015 at 21:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.