1 Reply Latest reply: Feb 1, 2011 9:47 PM by Cycles4Fun
Ruahine Level 1 (0 points)
I'm reasonably new to cocoa programming (am about 3/4 of the way through Hillegass' book). I want some advice as to what approach I should take (as in: make a new class that inherits from NSRadioButton or whatever) in order to achieve the following:
I want a panel in my window with a group of buttons with custom icons, but exactly one of which is selected at any time (i.e. like a radio button). However, the particular buttons that are in this group will change (if the user selects a different option then the buttons for that option will pop up instead). Furthermore I would like to be able to make so that when the user presses 'tab' then the next button in the group is selected.

If this is unclear let me know and I'll try and explain it better.
I can kind of see how to go about doing this (using custom views), but I suspect that there is a much much simpler solution (more interface builder and a lot less code).
Thanks in advance.

iMac 2.4GHz, Mac OS X (10.6.6)
  • Cycles4Fun Level 1 (5 points)
    Since you want to panel your window with these buttons, have you considered the NSCollectionView? I have done something similar in one of my programs. In it I needed the ability for a user to click to choose one of three selections. Then click a normal button to finalize the selection. In the NSCollectionViewItem I placed and image view. Then by managing the state of the collection view item I made it work just like a radio button. I used an two images. Both started with the same image except the second had a big check mark in it. I show the checked image with the item was selected.

    Hope this helps.