Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Using Radio Buttons

A radio button displays the setting of something in your application and is part of a group in which only one button can be on at a time. Use a group of radio buttons to choose among several options which are mutually exclusive.

Contents:

Standard Radio Buttons
Icon Radio Buttons


Standard Radio Buttons

A standard radio button is identified by a circle with a line of text. If the button’s off, the circle is empty. If the button is on, the circle is filled in. If the button is mixed-state, the circle has a dash in it.

For example, this group of buttons displays that all the selected objects are green:


Radio buttons with green option selected

And this group displays that some of the selected objects are red and some are green:


Multiple selection in radio buttons

A group of radio buttons is implemented with an NSMatrix object that contains several NSButton instances and has a tracking mode of NSRadioModeMatrix. Whenever one of the matrix’s button is clicked, the matrix turns off the previously selected button and turns on the newly clicked one.

It’s easiest to create a group of switch buttons in Interface Builder. You can also make one programmatically by creating an NSMatrix object with a tracking mode of NSRadioModeMatrix. Then create buttons with a type of NSRadioButton.

Icon Radio Buttons

You can also have a radio button that’s an icon button; that is, one that’s primarily identified by its icon and has little or no text. If the button’s off, it appears to be sticking in. If the button’s on, it appears to be pressed in. (An icon button cannot display the mixed state.)

You can create an group of icon radio buttons in either Interface Builder or programmatically. If you use Interface Builder, start with a matrix of push buttons. If you create it programmatically, create an matrix of buttons. Then change the matrix’s tracking mode to NSRadioModeMatrix. Change the buttons’ types to NSPushOnPushOffButton, their image positions to NSImageOnly, their bezel types to a square bezel type. Finally set their images to what you want.



< Previous PageNext Page > Hide TOC


Last updated: 2007-12-11




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice